PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: Bruce.Prentice on January 09, 2008, 03:35:24



Title: Handling mx:State and Mediator Creation
Post by: Bruce.Prentice on January 09, 2008, 03:35:24
First thanks for this framework.  It has been helping me a lot working on our new app here at my company.  I have one quick question.
Usually the controller will register the mediators with the framework.  In my main application.mxml I am using view states that will change depending on whether the user is logged in or not.  Only issue is that I cannot register the loggedIn viewstate because it is null at this time.  So I was wondering is it good practice for me to just wait, and then when I change states send notification to the controller to register the loggedIn mediator? 
 
This is what I was trying to do
                        override public function execute( note:INotification ) : void           
                        {
                                    facade.registerProxy(new CarrierListProxy() );
                                    facade.registerProxy(new WebTaskProxy() );
                                    facade.registerProxy( new GMCLoginProxy() );
                                   
                                    var webTaskProxy:WebTaskProxy = facade.retrieveProxy(WebTaskProxy.NAME) as WebTaskProxy
                                    webTaskProxy.findWebTasks(1,"HOME");
                                   
                                    var app:gmcps = note.getBody() as gmcps;
                                    facade.registerMediator( new ApplicationMediator(app));
                                    facade.registerMediator( new DownLoadFilesMediator(app.CustView.DLFILES))   <-- failed here because app.CustView is null (it is the logged in State)


Title: Re: Handling mx:State and Mediator Creation
Post by: Joel Hooks on January 09, 2008, 04:05:32
I would have a LoginCommand that registers that mediator. Since it isn't needed until that time anyway.