PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: rajah on March 29, 2010, 03:12:20



Title: Problem with proxy
Post by: rajah on March 29, 2010, 03:12:20
Greetings,

After developing with cairngorm for a long time i wanted to try out puremvc.
I understand most of the basics now but i'm having a problem with the proxy's.
When i register one, i can't check if i registered it.
:
if (!facade.hasProxy(getUserProxy.NAME))
{
trace(facade.hasProxy(getUserProxy.NAME));
facade.registerProxy( new getUserProxy());
}

If i run this code it keeps on saying it doesn't have the proxy yet and registers it again.
This way i can't get the data from my proxy.

But if i do the same with a mediator than this code works and i can retrieve the mediator.

Am i forgetting something special for a proxy?

Thanks in advance


Title: Re: Problem with proxy
Post by: puremvc on March 29, 2010, 09:41:28
getUserProxy should be proper. You're referring to a class variable. The class (should be) GetUserProxy if get is intended to be part of the proxy name). Also, be sure NAME is static.

-=Cliff>


Title: Re: Problem with proxy
Post by: rajah on March 30, 2010, 02:14:56
Well thnx for the as3 lesson cliff ;)
But changing the class name will not help me solve my problem.

NAME could have been the problem so i changed it to GETUSER, but when i run the code:
:
if (!facade.hasProxy(GetUserProxy.GETUSER))
{
trace(facade.hasProxy(GetUserProxy.GETUSER));
facade.registerProxy( new GetUserProxy());
}
It still keeps returning me "false" every time i run this. I expect it to be false the first time offcourse, but after that i think i should be registerd? But it doesn't.
What am i missing?


Title: Re: Problem with proxy
Post by: puremvc on March 31, 2010, 09:48:49
Now you're using GETUSER?

Should be GetUserProxy.NAME, right? And GetUserProxy.NAME should be static, and your GetUserProxy constructor is passing NAME to super as the first argument? And is not overriding getProxyName?

In GetUserProxy, it should look like:
:
public static const NAME:String = "GetUserProxy";

public function GetUserProxy()
{
   super( NAME );
}

And your code that is attempting to register the proxy if it doesn't exist:

:
if (!facade.hasProxy(GetUserProxy.NAME))
{
trace(facade.hasProxy(GetUserProxy.NAME));
facade.registerProxy( new GetUserProxy());
}


-=Cliff>


Title: Re: Problem with proxy
Post by: rajah on April 02, 2010, 04:15:43
ai i forgot the super..  :-\

thnx  :) it's working now