Data Transfer Object
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
package com.farata.dto{
// [RemoteClass] meta tag goes here if this DTO
// is used in Flex Remoting
[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;
}
}
}
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 ...
Get Agile Enterprise Application Development with Flex now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.