You'll want to set up a result event handler in your remote object. In
this function you should move the statement that acts on the returned
data (your getItemAt)
 
<mx:RemoteObject id="dataRO" destination="dotNetDestination"
source="dotNetObj" showBusyCursor="true">
  <mx:method makeObjectsBindable="true" name="getUserList"
result="{getUserList(event)}" fault="{getUserListFault(event)}" />
 </mx:RemoteObject>
 
Functions:
public function getUserListFault( event:FaultEvent):void{
    Alert.show("Database Fault "+ObjectUtil.toString(event.fault));
   }
public function getUserList( event:ResultEvent):void{
    myUserListVar = new ArrayCollection(); //zero out your list variable
    if(event.result.length){
        myUserListVar = event.result;
        doSomethingWithThis =  myUserListVar.getItemAt(0);
    }
   }

Darin Kohles, Application Developer
[EMAIL PROTECTED]
Digital Positions, Inc.
2289 Peachtree Road NE
Atlanta, GA 30309

404-351-2366 phone
404-351-4055 fax
http://www.d-p.com/ 

 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Justin
Nichols
Sent: Thursday, May 24, 2007 10:19 AM
To: [email protected]
Subject: [AFFUG Discuss] MVC, Object Instantiation/Population,
Asynchronous Calls


First off I'd like to introduce myself.  My name is Justin Nichols and I
work for Nexteppe Business Solutions and we deal in car dealer data/web
services.  We're working on a new system using Flex, WebORB, and a .NET
backend.  We're running into a conceptual issue concerning the
asynchronous calls being made when retrieving remote data.  We are new
to the Flex game so please forgive any ignorance I may show :)

Here's the basic problem and I have a feeling about what the solution
would be, but I wanted to ask:

1) We are setting up our system using MVC as best we can
2) We have written some .NET backend objects, and for this example let's
say we're needing to populate an ArrayCollection (flex-side) of User
objects.
3) We have our controller set to retrieve, using a RemoteObject call, an
ArrayCollection of User objects called userList.
4) The scenario we're in is the following:
    a) We have a button on the screen that when clicked we want to get
the userList and then perform some action using the userList.
    b) The button onclick event will send the necessary call to the
controller which will in turn make the call to the server and retrieve
the list.
    c) Immediately after the call is made to populate the userList
variable, another statement is written that will perform some action on
the userList (say userList.getItemAt() or whatnot).
    d) The issue at hand, is that because the call is asynchronous, the
userList may very well be null when the userList.getItemAt() gets
called.

Now from what I've read, we simply need to set up a custom event that
gets dispatched once the userList object has been filled.  However, the
problem then arises when we might have two separate UI operations that
would utilize the same userList object population methodology, so my
main question is, would we need to write an event handler for the
population of the userList object for each UI operation (thus knowing
what operation I'm really wanting to do once the userList object is
filled)?  Or is there some other best practice technique that I'm
missing here?

Also, is this an issue that frameworks such as Cairngorm can help with?

I really appreciate all the help in advance and again I hope I'm not
being too...noobish :)

Thanks,


-- 

Justin Nichols
Nexteppe Business Solutions
(877) 572-8892
[EMAIL PROTECTED]

------------------------------------------------------------- 
To unsubscribe from this list, simply email the list with unsubscribe in
the subject line 

For more info, see http://www.affug.com 
Archive @ http://www.mail-archive.com/discussion%40affug.com/ 
List hosted by FusionLink <http://www.fusionlink.com>  
------------------------------------------------------------- 



-------------------------------------------------------------

To unsubscribe from this list, simply email the list with unsubscribe in the 
subject line



For more info, see http://www.affug.com

Archive @ http://www.mail-archive.com/discussion%40affug.com/

List hosted by http://www.fusionlink.com

-------------------------------------------------------------

Reply via email to