I haven't stored channelsets, but generally, if you have any kind of data items that need to be accessed in more than one spot, the Model is the place to look. Manipulating the model is delegated to the Controller, which in the case of Cairgorm is generally a Command. ;)
Gareth,I'm a little late to this discussion, but I thought I through in my two cents. In your service locator you can bind the channelSet attribute to a dynamically created channelSet that is stored in your model locator. You create functions/ui to manipulate that model and the service locator, as a binding destination, will "know" about the model. However, I wouldn't kludge up your service locator - sure make it so you can manipulate it, but I would keep focused - just a service locator and nothing more. You could split hairs about where the manipulation logic lives. I happen to like using model locators and using binding.As far as your logic to test the various services, I'd definitely create a command class and delegates to do that. There's absolutely no reason why your Command class can't recursively check for status on a number of services and and when complete, modify your model locator, which in turn will notify the user of the results via the view. I've had good luck with using application states and binding the state to my model locator. This allows me to drive any number of transitions, property settings and functions when the application enters a state such as "SERVICES_INITTED".JeffOn Apr 1, 2008, at 6:05 PM, Gareth Edwards wrote:Robin,
Thanks for your response, I understand MVC most of the time, but I was a little unsure because of the nature of the service locator.
So is o.k for my view to know about the service locator?
To add methods to my service locator I will have to modify the Cairngorm EnterpriseServiceLocator, is this correct?
I have already modified it to work with BlazeDS (Messaging, without LC) so I don't have a big issue doing this if it is what is required.
Cheers
Gareth.
Robin Hilliard wrote:Hi Gareth,
Here's some answers assuming you subscribe to the gist of the MVC presentation I gave at WebDU last yearOn 01/04/2008, at 8:51 AM, Gareth Edwards wrote:Strictly speaking no, because the ServiceLocator is part of the business layer, and this would introduce a dependency on a particular model from your business layer (you could imagine the business layer being useful to many distinct Flex apps with different models). That said the model changes the least out of the MVC players so in some situations where the model and service were very closely interdependent you could argue that this wasn't too great a loss.I have created a some what complicated services.as(EnterpriseServiceLocator) and I'm trying to give some limited controlback to the end user, and allow them to select from a list of availableAMFChannels. I almost have it all working, but have a couple ofquestions before I continue to finish the work in this area.
- Is it o.k for my Service Locator to access the Model locator?
- Is it o.k for my Service Locator to modify the values in the Model?See above.I'd queue the requests, going with the philosophy that like DAOs on the server you are trying to hide the complexity of how the services work from the rest of the application. As far as the command knows, it makes the asynchronous call and it just takes a while to come back while some tests are done. In fact something like this happens anyway when Flash tests for the appropriate cross domain file on the server before making an RPC call.- How would you best manage your application to "WAIT" until various
checks on the AMFChannels are done before doing anything further ?
- Would it be better to create an Event / Command to do the required
logic to determine the AMFChannels and then use this to set the Model,
then have the service locator access the Model for read only?I would be inclined to keep the details of the selected channel in the Service Locator or a service in the Service Locator and not in the model.
I'd add methods to the service to get lists of channel set names and select the channel - the rest of the app doesn't need to know that they're channel sets, just choices like "unsecure", "secure" or whatever you have.
- When the user selects an available AMFChannel, the system needs to
move the selected Channel to the TOP of the ChannelSet
- I'm doing this by creating an array of AMFChannels, storing these
in the Model, then reading them into the service locator and ChannelSet
when required.
- How do I ensure no further actions take place until this update is
done.You could queue the calls - the neatest way (maybe gold-plating, but cute and useful) to do this would be to create a Proxy subclass that decorated your service and queued up function calls that it would play back when you set an enabled property to true. This is like the access control proxy pattern. There might be something in the SDK that does this already.HTH,Robin
ROBIN HILLIARD
Chief Executive Officer
robin@...
RocketBoots Pty Ltd
Level 11
189 Kent Street
Sydney NSW 2001
Phone +61 2 9323 2507
Facsimile +61 2 9323 2501
Mobile +61 418 414 341
www.rocketboots.com.au
--
: : ) Scott
Helping your grandma on the interweb
at: http://blog.criticalpile.com