O'Reilly logo

Agile Enterprise Application Development with Flex by Tony Hillerson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required