Flex Application Architecture
be accessing such as HTTP, Web Services, Flash Remoting, etc. Placing all of your services in one central area will be very manageable and extendable for the future. The Service Delegate is responsible for calling the actual server side methods on the server. It accesses those services by using the ServiceLocator to locate the server, and itself to actually invoke those methods. The Front Controlle r is responsible for capturing Cairngorm Events that are dispatched throughout the application, such as clicking of a button, initializing of a component, response from user interaction, etc. The FrontController then maps the captured event to the proper Command. The Command is responsible processing the event by running the Command class execute() method, thismethod is an ICommand interface method, which the Command implements. The Command is also responsible for updating
the ModelLocator, as well as invoking a server side service with the help of a Delegate. The Value Objec t represents an entity of something, the Value Object is nothing more than a representation of an item, or data structure, it just holds the attributes of data in which you are representing. The View , the view of your application in which will be presented to the user for interaction, the view is responsible for dispatching user or system-generated events. It also binds to the ModelLocator for data representation.
• Commands carry out the event, by updating the ModelLocator and/or calling services defined inside the Delegate • Views dispatch application wide events • Views watch data stored inside the ModelLocator • Views are visual components (buttons, panels, data grids, etc.) • Views can contain child views and components • Even
Overview
• ModelLocator holds data • Service Locator holds service locations • Delegate holds service methods • FrontController captures events and maps to proper Commands
Listing 1. ContactVO.as
package com.jonniespratley.flexcontacts.vo {
import com.adobe.cairngorm.vo.IValueObject;
[RemoteClass(alias="com.jonniespratley.flexcontacts.vo.ContactVO")]
[Bindable] public class ContactVO implements IValueObject { public var contact_id:int;
public var contact_fname:String; public var contact_lname:String; public var contact_email:String; public var contact_url:String; public var contact_address:String; public var contact_address2:String; public var contact_state:String;
public var contact_city:String; public var contact_zip:String; public function ContactVO( obj:Object = null ) { if ( obj != null ) { this .id = obj["id"]; this .name = obj["name"]; this .address = obj["address"];
this .city = obj["city"]; this .state = obj["state"]; this .country = obj["country"]; this .email = obj["email"]; this .phone = obj["phone"]; this .zip = obj["zip"]; this .date = obj["date"];
}
}
}
}
03/2009 (5)
53
Made with FlippingBook HTML5