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: Binding a value object into a proxy  (Read 7048 times)
reduxdj
Jr. Member
**
Posts: 11


View Profile Email
« 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
Logged
Rhysyngsun
Courseware Beta
Sr. Member
***
Posts: 51

Nathan Levesque

 - rhysyngsun@gmail.com  - rhysyngsun
View Profile WWW Email
« Reply #1 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.
Logged

Pages: [1]
Print