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: Can't Update ComboBox after Remote Call  (Read 7651 times)
Westside
Jr. Member
**
Posts: 12


View Profile Email
« on: November 26, 2008, 01:36:27 »

Hi,

I am new to PureMVC and Flex as well.

I have been struggling with this for a few hours and could use some assistance if possible.  I have a mediator called "HomePageMediator", this mediator is registered with a view component called "HomePage".  This registration happens in my "StartupCommand"

In "RemoteProxy.as"

// Result from Remote Call
public function result( event:Object ):void {   
    switch ( event.token.message.operation )   {
   case "getUSStates":
   sendNotification(STATES_LOADED)
    break;
    }
}

In "StartupCommand.as":
facade.registerMediator( new HomePageMediator( app.homePage ) );

In "HomePageMediator.as"
public function HomePageMediator( viewComponent:Object ) {
   super( NAME, viewComponent );
   homePage.addEventListener( HomePage.LOAD_STATES, onStates );

}

private function onStates( event:Event ):void   {
   sendNotification( ApplicationFacade.LOAD_STATES );
}
      
override public function listNotificationInterests():Array   {
   return [
      ApplicationFacade.LOAD_STATES,
      ApplicationFacade.STATES_LOADED
      ];
}
      
override public function handleNotification( note:INotification ):void      {
    switch ( note.getName() ){
   case ApplicationFacade.LOAD_STATES:
             .....
             break;
   
             case ApplicationFacade.STATES_LOADED:
      homePage.statesAC = note.getBody() as ArrayCollection;
      homePage.stateComboBox.dataProvider = note.getBody() as ArrayCollection;
   break;
   }
}

In "HomePage.mxml"
[Bindable] public var statesAC: ArrayCollection;


The STATES_LOADED case statement which appears in my "handleNotification" function seems to work, but my combo box does not get populated with the data returned from the Remote Service Call.  The Service call is working as I can see the data exist when I debug. 

I think am going wrong here "homePage.statesAC = note.getBody() as ArrayCollection;"  but I am not sure.

How do I map the result from the remote call to my combobox?  I assume the mediator I am using "HomePageMediator" should do this.

Sorry for the long post, hopefully it makes some sense.

-Westside
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: November 26, 2008, 07:27:14 »

Your not tossing the data from the proxy:

Do in "RemoteProxy.as"// case "getUSStates": 

sendNotification(STATES_LOADED,event.result )    break;    }}
Logged
Westside
Jr. Member
**
Posts: 12


View Profile Email
« Reply #2 on: November 26, 2008, 08:50:23 »

WOW!  That worked first time around.  Even though I am only doing basic stuff here, I am starting see how the pieces fit together and I am lovin' this!  Also, your best practices document is pretty sweet too.  It has helped me get going.

Thanks a lot!

-Westside
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: November 26, 2008, 09:00:04 »

No problem.  It helps that you quoted the just the salient bits of your code.  ;)

-=Cliff>
Logged
Pages: [1]
Print