Here's an example of why delegates are useful on the client. Our current Flex project is based on an existing XML backend. We have one service with a single "send()" method to send XML strings up to the server and get XML string responses. Because this will probably change in the medium term we don't want to expose our client code to the XML, so we modified the delegate by adding an onResult handler which parses the XML string into value objects before forwarding them to the original responder. Later on if the server changes only our delegates will be affected (and greatly simplified). Using delegates gave us the "elbow room" to make these modifications without impacting the rest of our client application.
In another Flash project we're working on the client development is ahead of the server development, so our delegates return dummy test data to the responder so that client development can continue.
You don't want to roll the delegate code into commands or elsewhere because multiple commands may reuse the same delegate.
In Cairngorm you would pass the array of customer vos back to the command that invoked the delegate. The command would then populate the view via a view helper (to keep the UI at "arms length" from the commands) - the view helper would either set the dataProvider directly or perhaps a public property of a view that was then bound to the dataGrid's dataProvider property.
Did you see the sample Cairngorm application I posted earlier this week?
Cheers,
Robin
http://www.rocketboots.com.au
On 03/02/2005, at 9:19 PM, [EMAIL PROTECTED] wrote:
Thank's Steven,
good work,
but according to you, considering that you know an architecture J2EE and
his complexity, i don't know the sense "to remap" buisiness delgate in
"Flex",
rather i have just build my business delegate in j2ee and i don't know
if exist a logical/technical justify can you light me!!! please.
For pojo it's ok i understand that it's necessary for amf/flex to swap
java/flex flex/java viceversa.
/*
in the case that this function returns me an array of customer,
it is possible to hook it to a dataProvider using the your
approach, for example in my Customer.mxml
as I can exploit here the under code?
for example
<mx: DataGrid dataProvider=??????
/*/
public function login( loginVO : LoginVO ): Void
{
var call = service.login( loginVO );
call.resultHandler = Delegate.create( Object( responder ),
responder.onResult );
call.faultHandler = Delegate.create( Object( responder ),
responder.onFault );
}
thanks a lot of and excuse me if I make you lose the time
Best
Devis
Steven Webster ha scritto:
>Hi Devis,
>
>
>
>>If you look at the file Services.mxml I don't understand as
>>ServiceLocator.as the class you/he/she able does to memorize
>>all the RemoteObjects, don't I see containers? Can someone
>>explain me this file mxml???
>>
>><cairngorm:ServiceLocator xmlns:mx =
>>"http://www.macromedia.com/2003/mxml" xmlns:cairngorm =
>>"com.iterationtwo.cairngorm.business. * ">
>>
>> <mx:RemoteObject id = "customerDelegate" source =
>>"com.iterationtwo.demo.business.CustomerDelegate"
>> protocol = "http" showBusyCursor = "true"
>> result = "event.call.resultHandler (event) "
>> fault = "event.call.faultHandler (event) ">
>> </ mx:RemoteObject>
>>
>></ cairngorm:ServiceLocator>
>>
>>
>
>So the idea of the ServiceLocator (as you'll know from j2ee) is to
>present an encapsulation of all service lookup; in RIAs we're talking
>about RemoteObject (tight java-coupling), WebService and HTTPService
>services.
>
>We used to advocate ServiceLocator as an ActionScript 2.0 class -
>it was a singleton class, with getInstance(), that encapsulated all
>the Flash Remoting integration that it was necessary to perform.
>
>However, Flex does *so* much more for us than plain-old Flash
>Remoting, so we made a decision for Cairngorm 0.9 to simplify
>the ServiceLocator down to an MXML file that is instantiated from
>your top-level Application, as a "registry" of services.
>
>By declaring all of your application services here, your business
>delegate can easily locate services, invoke them, and pass responses
>from the services back to the command classes that call them.
>
>In fact, by adding a ServiceLocator.as class with Flash Remoting
>logic in it (look at the ActionScript 2.0 dictionary for an example),
>you can use Cairngorm with Flash RIA as well -- we have done in the
>past (most recently for a project running in the National Space
>Museum in the UK !) and there are flexcoders on this list doing so
>as we speak.
>
>So - quite simply, declare all your services in the Services.mxml
>file, and then look at the business delegate class to see how the
>Service Locator is used to handle all the underlying invocation
>of services, and handling of asynchronous results.
>
>Best,
>
>Steven
>
>--
>Steven Webster
>Technical Director
>iteration::two
>
>This e-mail and any associated attachments transmitted with it may contain
>confidential information and must not be copied, or disclosed, or used by
>anyone other than the intended recipient(s). If you are not the intended
>recipient(s) please destroy this e-mail, and any copies of it, immediately.
>
>Please also note that while software systems have been used to try to ensure
>that this e-mail has been swept for viruses, iteration::two do not accept
>responsibility for any damage or loss caused in respect of any viruses
>transmitted by the e-mail. Please ensure your own checks are carried out
>before any attachments are opened.
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
Yahoo! Groups Links
• To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
• To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
• Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.