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: Using implicit getters in concrete mediators  (Read 7909 times)
eco_bach
Courseware Beta
Sr. Member
***
Posts: 81


View Profile Email
« on: July 29, 2009, 05:24:48 »

p35 of the best practices document
http://puremvc.org/component/option,com_wrapper/Itemid,30/

If I try duplicating the example, using the following in my LoginPanelMediator, loginPanel traces null. Also, shouldn't viewComponent in the implicit getter reference the Main class , passed in thru the body of the StartUpCommand?


//CODE START
// User clicked Login Button; try to log in
private function onTryLogin ( event:Event ) : void {

trace('loginPanel==='+loginPanel);//traces null
sendNotification( ApplicationFacade.LOGIN, loginPanel.loginVO );
}
// Cast the viewComponent to its actual type.
protected function get loginPanel() : LoginPanel {
return viewComponent as LoginPanel;
}

//CODE END
Logged
Neil Manuell
Courseware Beta
Sr. Member
***
Posts: 109


View Profile Email
« Reply #1 on: July 30, 2009, 11:59:22 »

are you using flex?
have you read the slacker tutorial?
http://puremvc.org/content/view/92/1/

the most likely cause of your problem is the deferred instantiation of the flex component you view wraps
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #2 on: July 31, 2009, 02:55:37 »


Also, shouldn't viewComponent in the implicit getter reference the Main class , passed in thru the body of the StartUpCommand?

The implicit getter would reference Main in the mediator for Main, often named ApplicationMediator.  But for other mediators, the getter references the viewComponent being mediated, in this case viewComponent LoginPanel.  The LoginPanel instance has been passed to the constructor of LoginPanelMediator.
----Philip
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: July 31, 2009, 04:08:26 »

Are you sure that you actually passed in a LoginPanel instance when you constructed the Mediator? Try putting a breakpoint (or trace if you prefer) in the constructor:

:
public function LoginPanelMediator( viewComponent:LoginPanel )
{
     super( NAME, viewComponent );
     trace ("in LoginPanelMediator constructor. viewComponent = "+viewComponent);
}

-=Cliff>
Logged
Pages: [1]
Print