Title: Binding a value object into a proxy Post by: reduxdj on March 19, 2008, 04:21:31 HI,
I am having a difficult time of passing the data parameter of an object in my proxy at creation time. I am new at this so I am trying to work from the documentation. public function LoginProxy ( data:Object = null) { how do I create a loginVO object on my main application and then make sure that when I create my loginProxy - I have my loginVO created in the constructor as "data", data is always null for me. Inside my LoginMediator, i am getting the result and I am working it like this... // User clicked Login Button; try to log in private function onTryLogin ( event:Event ) : void { sendNotification( ApplicationFacade.LOGIN, UrLogin.loginVO ); //trace (UrLogin.loginVO.username); loginProxy.login(UrLogin.loginVO); } Is the preceding best practice? or am i missing a step. Thanks, Patrick Title: Re: Binding a value object into a proxy Post by: Rhysyngsun on March 19, 2008, 04:31:06 PureMVC's Proxy takes two arguments in the constructor: the name of the Proxy and the data object. When you subclass Proxy you have two choices:
1. Pass a new VO to the data parameter in the base class constructor: public function LoginProxy () { super( NAME, new LoginVO() ); } 2. Pass it into you own constructor when you instantiate your Proxy (which is what you are doing). I'm guessing that when you create your LoginProxy your code looks like this: facade.registerProxy( new LoginProxy() ); In which case, the data parameter in your constructor defaults to null, and then gets passed to the base class constructor. |