- 浏览: 151666 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
zyq070:
version 自动增长的 你手动设值 相比之前的值已经变化 ...
Row was updated or deleted by another transaction (or unsaved-value mapping was -
中华神韵:
...
Java中从一个ArrayList删除重复的元素 -
Menuz:
logcat慢慢调,终会找到的。
The application has stopped unexpectedly -
右转随缘:
好抽象。。。
The application has stopped unexpectedly -
tsmg:
您好,我zend也配了,怎么就是不能正常调试呢?是不会用在EP ...
安装EPP的调试Zend Debugger
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. The user hits this button several times to place several orders, which in turn initiates the same number of remote calls. The user can also click different buttons, initiating calls to different destinations. Because of the asynchronous nature of remote calls in Flex, the results from each call can arrive at random times. When each result arrives to the client, it triggers a result event, which obediently calls the result handler function written by an application programmer. So far, so good. 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? The fact that you place an order to purchase a Sony TV first and a DVD player 10 seconds afterward doesn’t guarantee that results will arrive to your Flex application in the same order. 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. Because AsyncToken is a dynamic class, you can add any properties to this class during runtime, as is done with orderNumber in Example 2-20. You can also add one or more responders that will provide the result handling. Adding responders on the token level simplifies memory management. Example 2-20. Using the AsyncToken class AsyncToken is a local object. It is identified by a messageId that is passed with the request to the server. When the server responds, it includes a correlationId property in the message header, and Flex automatically calls the appropriate AsyncToken responders in the order they were defined. Example 2-20 calls the function send(), which starts with creating the AsyncToken instance. Then, you'll attach as many properties to this instance as you need. You may get the impression that something is not right�the values are being assigned to the instance of the token after the request has been sent to the server for execution. If so, when the result in the form of an AsyncToken comes back, it shouldn't contain values such as orderNumber and references to the responders, right? Wrong. In Example 2-20 , two responders were added to the placeOrder() request. In the case of successful order placement, two functions will be called: processOrderPlaced() and createShipment(). In the case of errors, the function processOrderFault()will be called. You can add an instance of a Responder object to a token on the fly, as was done in the earlier code snippet, or your can provide an existing instance of a class that implements the IResponder interface—that is, that has the functions result() and fault(). In the more traditional way of programming client/server communications, you define the handlers for results and faults: But using AsyncToken, you can assign the handlers during runtime as was done in Example 2-20 , which gives your application additional flexibility. At some point in time, the result will come back to the client and you can retrieve the token from the property ResultEvent.token and examine its dynamic properties (just the orderNumber in your case) that were originally added to the token: Using the Asynchronous Token design pattern allows Flex to efficiently map associated requests and responses without the need to introduce a multithreaded environment and create some mapping tables to avoid mixing up requests and responses.
...
private function sendOrder(/*arguments go here*/):void{
var token: AsyncToken = ord.placeOrder({item:"Sony TV"});
token.orderNumber="12345";
token.responder = new Responder(processOrderPlaced, processOrderFault);
token.addResponder(new Responder(createShipment,processOrderFault));
}
Flash Player executes your application’s requests in cycles driven by frame events. First, it performs the requests related to the modifications of the UI, then it gives a slice of time to process the application’s ActionScript code, and only after that does it take care of the network requests, if any. This means that all the code in the previous snippet will complete before the call ord.placeOrder({item:"Sony TV"}) is made. Always remember that from the developer’s perspective, Flex applications are single-threaded and responses are handled within each such cycle—even if the underlying communications are multithreaded.
To see a different way of assigning a responder, please revisit the code in Example 1-6 that demonstrates how Cairngorm’s Delegateclass adds a Command object as a responder. Sure enough, the Command object implements result() and fault() methods.
<mx:RemoteObject id="ord" destination="Orders" result="processOrderPlaced(event)" fault="processOrderFault(event)"/>
private function processOrderPlaced(event:ResultEvent):void {
myOrderNumber:Object = event.token.orderNumber;
// if myOrderNumber is 12345, process it accordingly
}
发表评论
-
js调用flash的方法时报错:Error calling method on NPObject!
2012-12-27 15:53 3067如题; uncaught exception: Error ... -
AIR 2.6 NativeProcess is not supported
2012-03-28 11:46 1850使用Flex AIR2.6开发桌面程序,添加程序自己重启或启动 ... -
AIR application killed when check camera device
2011-07-25 19:16 715I met this problem and spen ... -
UIComponent中的parentDocument和parent
2011-06-26 17:26 1551ParentAndParentDocument.mxml ... -
[Forward]How to compile CSS file in Flash Builder
2010-12-10 00:39 820It's so easy.Step1. Right click ... -
[Forward]Selected Design Patterns - Data Transfer Object
2010-12-05 00:18 901Data transfer objects are als ... -
[Forward]Selected Design Patterns - Mediator
2010-12-04 23:51 891Almost any complex screen of ... -
[Forward]Selected Design Patterns - Proxy
2010-12-04 23:20 743A proxy is an object that re ... -
[Forward]Selected Design Patterns - Singleton
2010-12-04 23:06 757From http://oreilly.com ... -
Debugging with Google Chrome and Flash Player 10.1
2010-09-19 11:53 1011http://polygeek.com/2780_flex_d ... -
If the porgram is already running, close it before attempting to run.
2010-08-24 17:29 1719Launch Failed! If the program ... -
DataGrid选不中行
2010-07-15 17:01 751I have noticed a strange behavi ... -
Avoiding duplicate session detected errors in LCDS (and BlazeDS)
2010-07-01 18:34 1420Original article path:http://ww ... -
Server.Processing.DuplicateSessionDetected
2010-07-01 16:58 1912Earlier i faced one issue ... -
USING FLEX 3 ADVANCEDDATAGRID IN FLASHDEVELOP
2010-05-14 16:54 1323Those of you attempting to u ... -
[转记]AS3中的continue和break新用法
2010-04-06 20:25 2695AS3中的continue(continue [label]) ... -
BlazeDS & Hibernate lazy loading in n-tier arhitecture
2010-03-01 10:42 875原文链接:http://forum.springsource. ... -
连接FMS,Hello Hailin
2009-11-13 18:50 822FMS 虽然已经升级到3.5版本, 但是仍然是支持AS1.5, ... -
从Flex3到Flex4的转变一览(样式应用、主题等)
2009-11-13 11:43 4561文章转载http://devilkirin.iteye.com ... -
关于flex事件的讲解
2009-09-20 17:03 1040文章来自:http://www.riachina.com/sh ...
相关推荐
Java codes to study patterns
Go Design Patterns-Packt(2017),Go设计模式,英文书籍,pdf格式,欢迎下载
GOF-设计模式-Design Patterns-英文原版-高清-有目录-有页码
JAVA设计模式一直是JAVA最考验内功的技术点。有句话说的很好,理解吃透设计模式概念如果是3分的难度,那么自己能写出来就是10分的...java-design-patterns-master是github上比较优秀的设计模式项目,这里与大家分享!
Design Patterns - Elements of Reusable Object-Oriented Software [English] Design Patterns 英文版 带书签 解压密码:123456
Head-First-Design-Patterns的官方源码,帮助你更好地学习Head-First-Design-Patterns。
head first design patterns-head first 设计模式的英文原版;高清英文原版,非扫描
好东西大家分享~~~~~~~~~~~
Design Patterns-Elements of Reusable Object-Oriented Software 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源...
Pro-Objective-C-Design-Patterns-for-iOS.pdf
Real-Time Design Patterns - Robust Scalable Architecture for Real-Time
php设计模式-designpatterns-php
https://github.com/kamranahmedse/design-patterns-for-humans 中文翻译,实例修改位JAVA代码
With Learning JavaScript Design Patterns, you’ll learn how to write beautiful, structured, and maintainable JavaScript by applying classical and modern design patterns to the language. If you want to...
Laracasts - design -patterns -in- php 课程资源
C# 设计模式 design-patterns-c-sharp
Practical-Python-Design-Patterns-Pythonic-Solutions-to-Common-Problems.pdf
Design Patterns-Elements of Reusable Object-Oriented Software + 源代碼
PDF-ProHTML5AndCSS3DesignPatterns-英文版.rar
b站李建忠讲的C/C+设计模式的ppt, ... 设计模式(Design pattern)是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可靠性。