Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: How to register dynamic components (Popups)  (Read 10453 times)
ghess
Courseware Beta
Jr. Member
***
Posts: 12


View Profile Email
« on: May 13, 2008, 02:16:17 »

Hi Folks,

New to ActionScript, puremvc so please bare with me.

In registering my Mediators I need reference to the UIComponent for the constructor. I have a Footer component that has a few links; About, Terms of Use, Privacy policy ect... My Footer has a mediator to listen to the link clicks dispatched and perform the associated action such as display a TitleWindow as a pop up. My About component has some other links allowing the user to navigate to the EULA, and some external url's so I felt it was just to have an AboutMediator to listen to the components dispatched events and decouple the About window functionality from the footer. My StartupCommand responsible for registering the mediators does not have the ability get a reference to the About component by drilling down through parentComp.footer.aboutWin because it is only instantiated at runtime. I tried to just have a member variable in the Footer.mxml component instantiated to an instance of the About.mxml component so I can reference it when registering the AboutMediator. When I run the application I get the following error:

Error: multitonKey for this Notifier not yet initialized!
   at org.puremvc.as3.multicore.patterns.observer::Notifier/get facade()[C:\Documents and Settings\Owner\My Documents\workspaces\PureMVC\PureMVC_AS3_MultiCore\src\org\puremvc\as3\multicore\patterns\observer\Notifier.as:89]
   at com.corp.prod.common.view::AboutMediator()[C:\dev\eclipse\workspaces\corp\proj\src\com\axentra\hipserv\common\view\AboutMediator.as:25]
   at com.corp.prod.modules.landingPage.controller::StartupCommand/execute()[C:\dev\eclipse\workspaces\copr\proj\src\com\corp\prod\modules\landingPage\controller\StartupCommand.as:43]

I am using the multicore version as I am employing a modular design, hoping my issue is not related, if so I can provide more info.

Any help much appreciated.

-Greg
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: May 13, 2008, 05:58:26 »

Your problem in this case is you're trying to access the Facade in the the Mediator constructor, which is not possible in MultiCore. You must wait until initializeNotifier before the facade is available.

See this post: http://forums.puremvc.org/index.php?topic=313.msg1213#msg1213

-=Cliff>
Logged
ghess
Courseware Beta
Jr. Member
***
Posts: 12


View Profile Email
« Reply #2 on: May 14, 2008, 10:19:23 »

Thanks Cliff, much appreciated, I missed that. Working now :-).

As far as my About.mxml and associated Mediator I chose to have a public member variable initialized in the parent component (Footer.mxml) so that I can register the Mediator in my StartupCommand by accessing footer.aboutWin to construct and register the AboutMediator. This seems ok for this module, however some of my more complex modules this would get quite ugly (drilling down several components deep) to access the UIComponent to build the Mediators. Should I be having my components register themselves? What is best practice, maybe my component design is overkill, but I like the reuse and encapsulation?

Cheers,

Greg
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: May 14, 2008, 03:25:29 »

You can have the mediator of a given view component create and register the mediators for the view components that are direct children of that view component.

Apply this methodology along the display hierarchy such that no mediator or command ever has to drill more than one level - accessing only a property name of the component in hand to get the new component to be mediated.

-=Cliff>
Logged
ghess
Courseware Beta
Jr. Member
***
Posts: 12


View Profile Email
« Reply #4 on: May 15, 2008, 01:42:23 »

Excellent, thank you.

-Greg
Logged
Pages: [1]
Print