PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: flexphp on March 28, 2008, 01:35:48



Title: nested custom components & their mediator: registration
Post by: flexphp on March 28, 2008, 01:35:48
Hi all,

Many many thanks for your work. Absolutly fabulous!

That said, all examples are quite basic in the way they deal with a single business object.
I'm trying to build up a demo application melting the skeleton app with the login app & the employeeAdmin app.

On top of those, I want to put ACL management (proxy) and form validation (custom class in the control dir)

I have working the skeleton app melted & the login app with form validation in one hand.
I have working the employeeAdmin app with acl management in the other hand.

Notice that thos 2 works are basics (only on BO each)

Problems arise when melting the two previous works:
I have problem for referencing nested view components for mediator registration:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
   xmlns:view="org.puremvc.as3.demos.flex.weborb.ecrud.application.view.components.*"
                 ...
      private var facade:ApplicationFacade = ApplicationFacade.getInstance();
                 ...
   <mx:ViewStack id="vwStack" left="0" top="0" right="0" bottom="20" resizeToContent="false" creationPolicy="auto">
      <mx:VBox/>
      <view:SplashScreen id="splashScreen" showEffect="{slideInEffect}" hideEffect="{fadeOut}" />
      <view:LoginPanel id="loginScreen" showEffect="{slideInEffect}" hideEffect="{fadeOut}" />
      <view:MainScreen id="mainScreen" showEffect="{fadeIn}" />
   </mx:ViewStack>

   <view:StatusControlBar id="statusControlBar" left="0" bottom="0" right="0" />

</mx:Application>

MainScreen.mxml is the following:

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
   xmlns:people="org.puremvc.as3.demos.flex.weborb.ecrud.application.view.components.*"
        ...
   <mx:VBox>
       <people:PeopleList id="peopleList" width="100%" />
      <mx:HBox>
         <people:PeopleForm id="peopleForm"/>
          <people:RolePanel id="rolePanel" width="280" height="100%"/>
      </mx:HBox>
   </mx:VBox>
</mx:Canvas>

ApplicationMediator is registered by a command at statup.

When registrering (in ApplicationMediator) the following mediators: PeopleListMediator, PeopleFormMediator, RolePanelMediator, what do I have to put there:

facade.registerMediator( new PeopleFormMediator( app.mainScreen.peopleForm ) );

Because app.mainScreen.peopleForm is null
 ???

The ideal would be to register PeopleFormMediator not in ApplicationMediator, but in MainScreenMediator, but it is even more complicated to me...

I would love your help.


Title: Re: nested custom components & their mediator: registration
Post by: puremvc on March 28, 2008, 05:02:24
Hi,

Unfortunately I'm on my Blackberry and away from the computer at the moment, so I can't easily site the specific threads here, but if you search these forums for 'deferred instantiation' you will find help with this issue. I do plan to add this to an advanced topics doc soon.

-=Cliff>


Title: Re: nested custom components & their mediator: registration
Post by: flexphp on March 29, 2008, 09:55:13
Hi Cliff,

'deferred instantiation' is the magic word.
I understood what was going on by reading the previous threads on that.

Short answer for readers in a hurry:

Nested UI componants may not be created at the time of registering the child mediators. Thus, the child mediator registration might not be done in the parent mediator constructor, but in a function of it binded to CreationComplete event fired from the child UI component.

Many thanks Cliff!

PS: having access to the Archecture 101 would have certainly saved me a lot of time...
But I'm fully rewarding to the PureMVC team and specially Cliff, who responds also to newbies like me.

 :)


Title: Re: nested custom components & their mediator: registration
Post by: puremvc on August 16, 2008, 04:15:54
Here's a link to the new FAQ entry for this issue:

http://puremvc.org/content/view/91/185/

-=Cliff>