- 浏览: 155916 次
- 性别:
- 来自: 成都
-
文章分类
最新评论
-
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
[Forward]Selected Design Patterns - Data Transfer Object
- 博客分类:
- Flex
Data transfer objects are also known as value objects (VOs) and are used for data exchanges between various application components, which can be either colocated in the same process or on remote computers. These DTOs can even be written in different programming languages, for example, Java and ActionScript. First, modify the application from the previous section and encapsulate the order details in a simple OrderDTO that will be placed in the event object and will happily travel between price and order panels. When this is done, you will spend some time with more advanced DTOs that you may want to use in Flex remoting. Example 2-12 is a simple OrderDTO.as that will be passed between the price and order panels. Example 2-12. OrderDTO.as In Example 2-13 ’s second version of the price panel, add a function startDataFeed(), emulating the real data feed that may be bringing the market data to the pricing panel. Please note that the PricePanel now displays the data from this “external” feed by binding the UI controls to the properties of the currentData object “received” from a remote server. Example 2-13. PricePanel2.mxml In Example 2-14 , the function placeOrder()dispatches the OrderEvent2with a packaged DTO inside. There is no need to declare multiple variables, as this was done in Example 2-9 . Example 2-14. OrderEvent2.as The new version of your driving application, Trading2.mxml (Example 2-15), does not assign the symbol, bid, and ask values to the price panel, as this was done for simplicity in Example 2-11 . Now the PricePanel is being populated by its own data feed. Example 2-15. The driving application, Trading2.mxml Even though you haven’t yet seen the code of the OrderPanel2, you can still use it, as long as its API is known—in this case, you know that it listens to the OrderEvent2. As a matter of fact, in many cases you’ll be using components without having any knowledge about how they operate inside. But to go easy on you, Example 2-16 shows you the source code of OrderPanel2.mxml, which receives the OrderEvent2, extracts the OrderDTO, and populates its UI controls. Example 2-16. OrderPanel2.mxml Examples 2-12 through 2-16 illustrated an application that used a DTO as a sort of exchangeable currency in the interaction between colocated Flex components. But DTOs also play an important role during the exchange of data with the server-side application using Flex remoting or Data Management Services. In such enterprise applications, the server-side team provides a DTO coded in one of the programming languages (this example uses Java), and the Flex team has to provide a similar Action-Script DTO. Flex RemoteObjector DataServiceclasses will serialize/deserialize these DTOs into each other, regardless of which direction they travel. If you don’t define DTOs on the Flex side, the data will be wrapped into ObjectProxy instances, which has a negative effect on performance. If you do, annotate Flex DTOs with the [RemoteClass...] meta tag or via the registerClassAlias() function call. We highly recommend using strongly typed data transfer objects, as opposed to dynamic objects or XML for data exchange between the client and server tiers. If you are working with a Java Server, make your Java (methods) accept/return custom classes and not generic map objects. The following list gives you some generic recommendations about creating DTOs that are meant for communication with a remote subsystem, and then offers a solution that can automate the process of creating ActionScript DTOs from their Java peers. This is yet another technique (remember wrapping up an object in a proxy?) for customizing the behavior of the objects when the data is being changed. Imagine that you need to create your own version of a data management service and want to maintain a collection of changed objects that remember all modifications in a DataGrid that uses a collection of OrderDTO objects as a data provider. You can maintain a collection of changed objects that remember all old and new values. If you are creating DTOs for the data exchange between Java and ActionScript classes using subclassing, both ActionScript classes will have the meta tag [RemoteClass] pointing to the same Java DTO. This won’t be an issue; Flex is smart enough to use the subclass for serialization. In the real world, an enterprise project’s Flex and Java developers often belong to different teams and if Java folks change the structure of their DTOs, Flex developers need to ensure that the structure of their classes is updated accordingly. There are different ways of automating this process, as shown in Example 2-17 . DTO2Fx is a free plug-in that’s available at http://www.myflex.org . It generates ActionScript DTO classes using the subclassing technique described earlier. Consider the Java DTO in Example 2-17 . Example 2-17. Annotated OrderDTO2.java The DTO2Fx plug-in uses Java annotations in the process of generating ActionScript classes, and @FXClass is such an annotation. The rest of the process is simple. As soon as you create or modify this class, it automatically regenerates a couple of ActionScript classes: _OrderDTO2.as and OrderDTO2.as. You can find more details about this process in the User Guide of DTO2Fx, but for now just examine the generated code in Example 2-18. Example 2-18. Superclass _OrderDTO2.as Example 2-18 is a superclass that will always be regenerated by DTO2Fx anytime the Java class changes. This class has a unique object identifier (uid) and includes getters and setters that will dispatch propertyChange events when the time comes. The code of the class OrderDTO2 is shown in Example 2-19 . This class is generated only once and is a subclass of _OrderDTO2.as. This is a place for an application developer to add application-specific customization, such as the addition of new properties and/ or functions. This class will never be overridden by DTO2Fx, regardless of what was changed in OrderDTO2.java. Example 2-19. Subclass OrderDTO2.as We hope that our message to you is clear now: the use of DTOs is a preferred way of designing interobject communications.
package com.farata.dto {
// [RemoteClass] meta tag goes here if this DTO
// is used in Flex Remotin
[Bindable]
public class OrderDTO {
public var symbol:String;
public var bid:String;
public var ask:String;
public var buy:Boolean;
//a buy/sell flag
public function OrderDTO(symbol:String, bid:String, ask:String,
buy:Boolean=false) {
this.symbol=symbol;
this.bid=bid;
this.ask=ask;
this.buy=buy;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="230" height="100"
backgroundColor="#D4E5D9">
<mx:TextInput x="0" y="-1" width="228" backgroundColor="#0DF113"
text="{currentData.symbol}" fontWeight="bold" fontSize="19"
textAlign="center"/> <mx:Label x="39" y="31" text="Bid" fontWeight="bold" fontSize="14"/> <mx:TextArea x="1" y="49" width="109" height="47" backgroundColor="#EBF4A2"
text="{currentData.bid}" fontSize="22" fontStyle="normal" fontWeight="bold" click="placeOrder(true)" editable="false" creationComplete="startDataFeed()"/>
<mx:Label x="154" y="31" text="Ask" fontWeight="bold" fontSize="14"/>
package com.farata.events{
import com.farata.dto.OrderDTO; import flash.events.Event;
public class OrderEvent2 extends Event {
public var orderInfo: OrderDTO; public var eventType:String;
public static const PREPARE_ORDER_EVENT:String ="OrderEvent"; public static const PLACE_ORDER_EVENT:String ="PlaceOrderEvent";
public function OrderEvent2(eventType:String, order:OrderDTO ) {
super(eventType,true, true); // let it bubble this.orderInfo=order; // store the orderDTO
this.eventType=eventType;
}
override public function clone():Event {
return new OrderEvent2(eventType,orderInfo);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:comp="com.farata.components.*" backgroundColor="white" applicationComplete="this.addEventListener(
OrderEvent2.PREPARE_ORDER_EVENT,orderEventHandler)" >
<mx:Label text="Price Panel" y="4" height="23" x="69" fontSize="16"
fontWeight="bold"/>
<mx:Label text="Order Panel" y="4" height="23" x="290" fontSize="16"
fontWeight="bold"/>
<comp:PricePanel2 y="31" x="7"/>
<comp:OrderPanel2 id="ordPanel" x="245" y="30"/>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import com.farata.events.OrderEvent2;
private function orderEventHandler(evt:OrderEvent2):void{
// The mediator decides what to do with the received event
// In this case it forwards the order received
// from PricePanel to OrderPanel
var orderEvt: OrderEvent2= new OrderEvent2(OrderEvent2.PLACE_ORDER_EVENT,evt.orderInfo);
ordPanel.dispatchEvent(orderEvt);
}
]]>
</mx:Script>
</mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="230" height="100"
backgroundColor="#4CF3D2" creationComplete="this.addEventListener(OrderEvent2.PLACE_ORDER_EVENT,orderEventHandler)">
<mx:Text id="sym" x="0" y="10" width="61" fontWeight="bold" fontSize="19"/>
<mx:Text id="operation" x="81" y="10" fontSize="19"/>
<mx:Text id="price" x="48" y="37" width="91" fontWeight="bold" fontSize="16"/>
<mx:Label x="5" y="65" text="Qty:" fontSize="19" fontWeight="bold"/>
<mx:TextInput id="qty" x="70" y="69" width="71" text="100" fontSize="16" selectionBeginIndex="0" selectionEndIndex="5"/>
Use an ArrayCollectionof such bindable DTOs as a dataProviderin your DataGrid, List, and similar components. Imagine a collection of objects with complex structure, with class variables of non-primitive data types—for example, a collection of Employee objects in which each object has a variable of type WorkHistory, which is a class with its own properties. If a variable declared in the WorkHistory class gets modified, the collection of Employee objects won’t know about this change unless you explicitly dispatch the propertyChange event.
For instance, instead of sorting orders by the DTO’s property symbol, you’d sort by symbol and uuid. In this case, the autogenerated hash value of each DTO will be unique for each record, which will result in better performance.
[Bindable(event="propertyChange")]
There’s a difference between the [Bindable(event="propertyChange")] and [Bindable]meta tags. The former syntax instructs the Flex compiler to generate code watching the propertyChange events. The latter syntax forces the Flex compiler to generate the event—it replaces the property with a setter/getter pair in which the setter’s role is to dispatch the event. But if your code has taken care of event dispatching already, you may wind up with events being dispatched twice!
[Bindable(event="propertyChange"]
public function get totalOrderAmount():Number {
return price*totalShares;
}
package com.farata.dto;
import com.farata.dto2fx.annotations.FXClass;
@FXClass
publicclass OrderDTO2 {
public String symbol;
public String bid;
public String ask;
public Boolean buy;
public OrderDTO2(String symbol, String bid,String ask, Boolean buy) {
this.symbol=symbol;
this.bid=bid;
this.ask=ask;
this.buy=buy;
}
}
package com.farata.dto {
import mx.events.PropertyChangeEvent;
import flash.events.EventDispatcher; import mx.core.IUID; import mx.utils.UIDUtil;
/* [ExcludeClass] */
public class _OrderDTO2 extends flash.events.EventDispatcher implements mx.core.IUID {
/* Constructor */
public function _OrderDTO2():void {
super();
}
// implementors of IUID must have a uid property
private var _uid:String;
[Transient]
[Bindable(event="propertyChange")]
public function get uid():String {
// If the uid hasn't been assigned a value, just create a new one.
if (_uid == null) {
_uid = mx.utils.UIDUtil.createUID();
}
return _uid;
}
public function set uid(value:String):void {
const previous:String = _uid;
if (previous != value) {
_uid = value;
dispatchEvent( mx.events.PropertyChangeEvent.createUpdateEvent( this, "uid", previous, value));
}
}
/* Property "ask" */
private var _ask:String;
[Bindable(event="propertyChange")]
public function get ask():String {
return _ask;
}
public function set ask(value:String):void {
const previous:String = this._ask;
if (previous != value) {
_ask = value;
const ev:mx.events.PropertyChangeEvent =
mx.events.PropertyChangeEvent.createUpdateEvent(
this, "ask", previous, _ask);
dispatchEvent(ev);
}
}
/* Property "bid" */
private var _bid:String;
[Bindable(event="propertyChange")]
public function get bid():String {
return _bid;
}
public function set bid(value:String):void {
const previous:String = this._bid;
if (previous != value) {
_bid = value;
constev:mx.events.PropertyChangeEvent = mx.events.PropertyChangeEvent.createUpdateEvent( this, "bid", previous, _bid); dispatchEvent(ev);
}
}
/* Property "buy" */
package com.farata.dto {
[RemoteClass(alias="com.farata.dto.OrderDTO2")]
public class OrderDTO2 extends com.farata.dto._OrderDTO2 {
/* Constructor */
public function OrderDTO2():void {
super();
}
}
}
发表评论
-
js调用flash的方法时报错:Error calling method on NPObject!
2012-12-27 15:53 3182如题; uncaught exception: Error ... -
AIR 2.6 NativeProcess is not supported
2012-03-28 11:46 1892使用Flex AIR2.6开发桌面程序,添加程序自己重启或启动 ... -
AIR application killed when check camera device
2011-07-25 19:16 760I met this problem and spen ... -
UIComponent中的parentDocument和parent
2011-06-26 17:26 1590ParentAndParentDocument.mxml ... -
[Forward]How to compile CSS file in Flash Builder
2010-12-10 00:39 858It's so easy.Step1. Right click ... -
[Forward]Selected Design Patterns - Asynchronous Token
2010-12-05 00:32 978Consider an enterprise applic ... -
[Forward]Selected Design Patterns - Mediator
2010-12-04 23:51 928Almost any complex screen of ... -
[Forward]Selected Design Patterns - Proxy
2010-12-04 23:20 799A proxy is an object that re ... -
[Forward]Selected Design Patterns - Singleton
2010-12-04 23:06 784From http://oreilly.com ... -
Debugging with Google Chrome and Flash Player 10.1
2010-09-19 11:53 1047http://polygeek.com/2780_flex_d ... -
If the porgram is already running, close it before attempting to run.
2010-08-24 17:29 1769Launch Failed! If the program ... -
DataGrid选不中行
2010-07-15 17:01 787I have noticed a strange behavi ... -
Avoiding duplicate session detected errors in LCDS (and BlazeDS)
2010-07-01 18:34 1465Original article path:http://ww ... -
Server.Processing.DuplicateSessionDetected
2010-07-01 16:58 1966Earlier i faced one issue ... -
USING FLEX 3 ADVANCEDDATAGRID IN FLASHDEVELOP
2010-05-14 16:54 1368Those of you attempting to u ... -
[转记]AS3中的continue和break新用法
2010-04-06 20:25 2743AS3中的continue(continue [label]) ... -
BlazeDS & Hibernate lazy loading in n-tier arhitecture
2010-03-01 10:42 913原文链接:http://forum.springsource. ... -
连接FMS,Hello Hailin
2009-11-13 18:50 870FMS 虽然已经升级到3.5版本, 但是仍然是支持AS1.5, ... -
从Flex3到Flex4的转变一览(样式应用、主题等)
2009-11-13 11:43 4601文章转载http://devilkirin.iteye.com ... -
关于flex事件的讲解
2009-09-20 17:03 1076文章来自:http://www.riachina.com/sh ...
相关推荐
selected shapes.<END><br>20 , splash.zip This demonstrates how to create a splash form for your program.<END><br>21 , menustat.zip This shows how to display information about the menu item in a ...
外加热强制循环蒸发器装配图(CAD).rar
数控车床纵向进给系统设计.zip
j
爬虫 bangumi名称和评论数
基于SpringBoot的垃圾分类回收系统,系统包含两种角色:管理员、用户主要功能如下。 【用户功能】 首页:浏览垃圾分类回收系统信息。 个人中心:管理个人信息,查看历史记录和订单状态。 运输管理:查看运输信息,垃圾回收的时间和地点。 公告管理:阅读系统发布的相关通知和公告。 垃圾回收管理:查看垃圾回收的信息,回收类型和进度。 垃圾出库申请管理:提交和查看垃圾出库申请的状态。 【管理员功能】 首页:查看垃圾分类回收系统。 个人中心:管理个人信息。 管理员管理:审核和管理注册管理员用户的信息。 用户管理:审核和管理注册用户的信息。 运输管理:监管和管理系统中的运输信息。 公告管理:发布、编辑和删除系统的通知和公告。 垃圾回收管理:监管和管理垃圾回收的信息。 垃圾出库申请管理:审批和管理用户提交的垃圾出库申请。 基础数据管理:管理系统的基础数据,运输类型、公告类型和垃圾回收类型。 二、项目技术 编程语言:Java 数据库:MySQL 项目管理工具:Maven 前端技术:Vue 后端技术:SpringBoot 三、运行环境 操作系统:Windows、macOS都可以 JDK版本:JDK1.8以上都可以 开发工具:IDEA、Ecplise、Myecplise都可以 数据库: MySQL5.7以上都可以 Maven:任意版本都可以
内容概要:本文档是台湾大学计算机科学与信息工程系2021年秋季学期《算法设计与分析》课程的第一次作业(Homework#1)。作业包含四道编程题和三道手写题,旨在考察学生对算法设计和分析的理解与应用能力。编程题涉及汉诺塔、数组计算、矩形点对、糖果分配等问题;手写题涵盖渐近符号证明、递归方程求解、幽灵腿游戏优化、不公平的卢卡斯问题等。文档详细描述了每个问题的具体要求、输入输出格式、测试用例以及评分标准。此外,还提供了编程技巧和注意事项,如避免延迟提交、正确引用资料、处理大输入文件等。 适合人群:具备一定编程基础的本科生或研究生,特别是修读过或正在修读算法设计与分析相关课程的学生。 使用场景及目标:①帮助学生巩固课堂所学的算法理论知识;②通过实际编程练习提高解决复杂问题的能力;③为后续更深入的学习和研究打下坚实的基础。 其他说明:此作业强调团队合作和个人独立思考相结合的重要性,鼓励学生在讨论后用自己的语言表达解决方案,并注明参考资料。对于编程题,特别提醒学生注意输入文件可能较大,建议采取适当的优化措施以确保程序运行效率。
基于SpringBoot的铁路订票管理系统,系统包含两种角色:管理员、用户主要功能如下。 【用户功能】 首页:浏览铁路订票管理系统的主要信息。 火车信息:查看火车的相关信息,包括车次、出发地、目的地和票价等。 公告资讯:阅读系统发布的相关通知和资讯。 后台管理:进行系统首页、个人中心、车票预订管理、车票退票管理等操作。 个人中心:管理个人信息,查看订单历史记录等。 【管理员功能】 首页:查看铁路订票管理系统。 个人中心:修改密码、管理个人信息。 用户管理:审核和管理注册用户的信息。 火车类型管理:管理系统中的火车类型信息。 火车信息管理:监管和管理系统中的火车信息,添加、编辑、删除等。 车票预订管理:处理用户的车票预订请求。 车票退票管理:处理用户的车票退票请求。 系统管理:管理系统的基本设置,公告资讯、关于我们、系统简介和轮播图管理。 二、项目技术 编程语言:Java 数据库:MySQL 项目管理工具:Maven 前端技术:Vue 后端技术:SpringBoot 三、运行环境 操作系统:Windows、macOS都可以 JDK版本:JDK1.8以上都可以 开发工具:IDEA、Ecplise、Myecplise都可以 数据库: MySQL5.7以上都可以 Maven:任意版本都可以
塑料架注射模具设计.rar
基于json文件数据驱动的的接口测试框架
铁丝缠绕包装机设计-缠绕盘设计.rar
linux
圆柱体相贯线焊接专机工作台设计.rar
硬币分拣机设计.rar
内容概要:本文探讨了开发行业级机器学习和数据挖掘软件的经验与教训,指出当前研究界与工业界之间的脱节问题。作者分享了开发LIBSVM和LIBLINEAR的经验,强调了用户需求的重要性。大多数用户并非机器学习专家,期望简单易用的工具来获得良好结果。文章还详细介绍了支持向量机(SVM)的实际应用案例,包括数据预处理(如特征缩放)、参数选择等步骤,并提出了为初学者设计的简易流程。此外,作者讨论了在设计机器学习软件时应考虑的功能选择、选项数量、性能优化与数值稳定性等问题,强调了软件开发与实验代码的区别以及鼓励研究人员参与高质量软件开发的重要性。 适合人群:对机器学习软件开发感兴趣的科研人员、工程师及从业者,尤其是那些希望了解如何将学术研究成果转化为实际可用工具的人士。 使用场景及目标:①帮助非机器学习专家的用户更好地理解和使用机器学习方法;②指导开发者在设计机器学习软件时考虑用户需求、功能选择、性能优化等方面的问题;③促进学术界与工业界之间的合作,推动高质量机器学习软件的发展。 其他说明:本文不仅提供了具体的开发经验和技巧,还呼吁建立激励机制,鼓励更多研究人员投入到机器学习软件的开发中,以解决当前存在的研究与应用脱节的问题。
一天入门pandas代码
该资源为joblib-0.12.0-py2.py3-none-any.whl,欢迎下载使用哦!
内容概要:本文档《xtuner_requirements.txt》列出了用于支持特定项目(可能是机器学习或深度学习项目)运行所需的所有Python包及其版本。其中不仅包括常见的数据处理和科学计算库如numpy、pandas,还包括了与深度学习密切相关的库如torch、transformers等。值得注意的是,文档中还特别指定了NVIDIA CUDA相关组件的具体版本,确保了GPU加速环境的一致性和兼容性。此外,文档中也包含了从GitHub直接安装的xtuner库,明确了具体的提交哈希值,保证了代码来源的精确性。 适合人群:对机器学习、深度学习领域有一定了解并需要搭建相应开发环境的研发人员,尤其是那些希望复现特定实验结果或基于已有模型进行二次开发的研究者和技术爱好者。 使用场景及目标:①帮助开发者快速搭建完整的开发环境,确保所有依赖项正确无误;②为研究人员提供一个稳定的实验平台,以便于重复实验和验证结果;③作为项目协作的基础,确保团队成员之间的环境一致性,减少因环境差异带来的问题。 阅读建议:由于该文档主要为技术性依赖列表,在阅读时应重点关注所需安装的库及其版本号,特别是CUDA相关组件和自定义库(如xtuner)的安装方式。对于非技术人员而言,可能需要额外查阅相关资料来理解各库的作用。同时,在实际操作过程中,建议按照文档中的顺序逐一安装依赖,避免版本冲突等问题的发生。
j
液氮带控制点工艺流程图.rar