Home > Flex, Uncategorized > Flex 4: Asynchronous Token

Flex 4: Asynchronous Token

Flex is all about Event Driven Development

Consider an enterprise application in which a user can place purchase orders for some
parts and request price quotes from various suppliers. In this case, the user may click
several buttons, resulting in server-side calls to one or more destinations. On each click
event of the button, a RemoteObject sends a new request to the server.

Here’s the million-dollar question: how can the application code map arriving result
objects back to the initial requesters if they can come back to the client in an arbitrary
order?.

Ans: Asynchronous Token Pattern
The goal of the Asynchronous Token pattern is to properly route the processing on the
client in response to the data arriving asynchronously from the server.

OK, How do i design using it:
Flash 4 Builder can generate CallResponders for your service calls and what you all have
to do is write your business logic.
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
protected function getHelloString():void
{
getHelloStringResult.token = excelDbService.getHelloString();
}
protected function getHelloStringResult_resultHandler(event:ResultEvent):void
{
Alert.show( getHelloStringResult.lastResult);
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id=”getHelloStringResult” result=”getHelloStringResult_resultHandler(event)”/>
<services:ExcelDbService id=”excelDbService” fault=”Alert.show(event.fault.faultString + ‘\n’ + event.fault.faultDetail)” showBusyCursor=”true”/>
</fx:Declarations>
reference: Enterprise Development with Flex and Flash 4 tutorials
Advertisements
Categories: Flex, Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: