PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: czw888 on July 20, 2010, 02:40:47



Title: How to register Mediator of children components
Post by: czw888 on July 20, 2010, 02:40:47
My main view component is call children components as follows:

     
:
var classRefrence:Class=getDefinitionByName(podList[i].podcomponent) as Class;
        var myvbox:Object=new classRefrence() as Object;
myvbox.dataProvider=mlotterylist;
pod.addChild(myvbox as DisplayObject);
   
   
myvbox is load the children component.Now, I have a children component named "AddRecordForm" and the mediator named "AddRecordListMediator".How do register AddRecordListMediator?


Title: Re: How to register Mediator of children components
Post by: puremvc on July 22, 2010, 07:48:31
A good way is to have a mediator that is attached upstream (like at the application level) that listens for the bubbling event that is dispatched when the component is added to the view hierarchy. This contains a reference to the newly added component, and you can wrap the appropriate mediator around it. Check out the Slacker flex demo for one approach to this. In that case it's components that are added to the view hierarchy by deferred instantiation, but the concept is the same.

-=Cliff>