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: facade has proxy but it is null  (Read 10510 times)
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« on: October 15, 2008, 03:54:55 »

Hi,

I'm trying to retrieve a proxy from the facade but it comes null... dont understand why since its being constructed and initialized correctly.

This is what i'm doing:

accessProxy = facade.retrieveProxy(AccessProxy.NAME) as AccessProxy;

var loginVO:LoginVO = note.getBody() as LoginVO;
         var accessProxy:AccessProxy;
         
         if (facade.hasProxy(AccessProxy.NAME)) {
         
            accessProxy = facade.retrieveProxy(AccessProxy.NAME) as AccessProxy;
            
            if (accessProxy!=null)
               accessProxy.login(loginVO);
            else
               mx.controls.Alert.show("null proxy");
         }
         else {
            mx.controls.Alert.show("Couldn't obtain proxy");
         }

The proxy exists but it comes null.

Any tips?

Thanks,

Nuno Santos
Logged
muraliobla
Newbie
*
Posts: 1


View Profile Email
« Reply #1 on: November 18, 2008, 08:08:29 »

Am also doing the same thing. My facade has the Command --> Proxy registered correctly. But while retrieving the proxy in the Test code, it's coming as null always. Any idea?

In Test case
==========
import com.blah.testapp.ApplicationFacade;
import com.blah.testapp.model.StockQuoteProxy;

var testAppProxy:TestAppProxy = TestApp.facade.retrieveProxy(TestAppProxy.NAME) as TestAppProxy;

App has the following
================
TestApp.mxml:
public static const NAME:String = 'TestApp';
public static var facade:ApplicationFacade = ApplicationFacade.getInstance(NAME);
   private function onCreationComplete() : void
   {
       facade.startup(this);
   }


Facade:
      override protected function initializeController() : void {
         super.initializeController();
          registerCommand(Notification.TEST_APP_COMMAND, TestAppCommand);
      }

Command:
        var testAppProxy:TestAppProxy =
         facade.retrieveProxy(TestAppProxy.NAME) as TestAppProxy;
         if (testAppProxy == null) {
            facade.registerProxy(testAppProxy = new TestAppProxy());
         }
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: November 20, 2008, 08:48:49 »

Use the debugger. Set a breakpoint on the line where you retrieve the proxy and run in debug mode. When it stops on the breakpoint, check the variables (turn on 'Flex->Show inacessable member variables on the variables view menu; the little down arrow on the right side) so you can see everything.

If its there, then do 'step into' ant step through the code a line at a time and see where the ball is dropped. From your example, I don't see the type of your local var called accessProxy. Is it defined as var accessProxy:AccessProxy?

BTW, if you're not using Flex Builder, this is why its woth buying. Trace statments are from the stone age. :)

Cheers,
-=Cliff>
Logged
Pages: [1]
Print