If I understand your situation correct, it sounds to me like you need to get
the userList sooner -- Either when the application loads or when the module
loads. That way, you won't have the null userList problem.
Cairngorm has the idea of a ModelLocator -- A specific class that's
responsible for keeping all the app's data. Unless I need the full
functionality of Cairngorm, I would just create my own model and/or
controller classes that keep up with the model for me. This would solve the
problem you mentioned about wanting to access the data from two different
places/events. If you want to look at Cairngorm, Scott Talsma did a great
presentation on it a couple of months ago. Look up his presentation on the
AFFUG website.
I hope this helps!
Clarke
_____
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
-------------------------------------------------------------