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
PureMVC Architects Lounge
Announcements and General Discussion
Architecture
Can't Update ComboBox after Remote Call
Pages: [
1
]
« previous
next »
Author
Topic: Can't Update ComboBox after Remote Call (Read 7651 times)
Westside
Jr. Member
Posts: 12
Can't Update ComboBox after Remote Call
«
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
Re: Can't Update ComboBox after Remote Call
«
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
Re: Can't Update ComboBox after Remote Call
«
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
Re: Can't Update ComboBox after Remote Call
«
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
]
« previous
next »
Stack Overflow
GitHub
Linked In
Google Plus
Twitter
Powered by SMF 2.0.15
|
SMF © 2006-2007, Simple Machines LLC
|
Content © 2006-2018, Futurescale, Inc.
Loading...