To code an AIR application that synchronizes with ColdFusion, include the cfair.swc file in your AIR project. This file contains all the ColdFusion client-side code to support interactions between AIR and ColdFusion. The file is installed with ColdFusion in the_ cf_webroot_/CFIDE/scripts/AIR directory. In Flash Builder, specify the swc file location in the Project > Properties > FlexBuildPath > Library Path > Add SWClibrary dialog.

Data object

The AIR application represents the managed data in an ActionScript object that corresponds to the ColdFusion-side data CFC. For example, in the Employee example, the AIR application has an Employee.as file containing an Employee ActionScript class that corresponds to ColdFusion employee.cfc:

package test.basic
{
[Bindable]
[RemoteClass(alias="AIRIntegration.employee")]
[Entity]
public class Employee
{
/** The user id of the employee **/
[Id]
public var id:int;
public var firstName : String;
public var lastName : String;
public var displayName : String;
....
public var countryCode : String = 'US';
....
}

Note: You do not need to create any SQLite databases or tables; they are created automatically. For example, once the Employee class is defined as above, the first time you invoke the class, the equivalent SQLite table is created for server data persistence.

Data object metadata

You use the following metadata to define the data object:

Metadata Element

Purpose

Entity

Specifies that instances of this class can be persisted to the SQLite database. This element is required.

Table(name="tableName")

The name of the SQLite table in which the object is to be stored. Defaults to the name of the class.

Id

Precedes a field definition. Indicates that the field is a primary key in the table. For composite keys, use Id tags on all the primary key fields.

Transient

A Boolean value specifying whether the property or field is persistent. A True value indicates that the field is not persistent and so it is not a part of the client side Sqlite table.

Column(name="name", columnDefinition="TEXT),

Specifies the SQLite database column that contains data for this field.
name: Column name. If not specified, defaults to the property name.
columnDefinition: The SQL Datatype to use for the column.
nullable: Specifies whether a field can have a null value.
unique: Specifies whether the value for each field must be unique within the column.

RemoteClass

Used for all remote objects, not just ColdFusion. The alias attribute identifies the corresponding class on the remote server. This information is used to map between ActionScript data types and the remote data types.It is mandatory that you specify the RemoteClass metadata tag for the ActionScript classes or entities that map with the server-side CFC. If you do not specify this metadata tag, you get a runtime error. For example, you specify the alias name for the Address entity as follows: RemoteClass(alias="myFolder.AIRIntegration.Address")The alias name must be unique within the AIR application.

Note: For private properties in a class, set Column metadata on the accessor functions (getxxx and setxxx) and not on the private property, as shown in the following code:

private var name:String; // Private property
[Column(name="FNAME",columnDefinition="VARCHAR")]
public function set fname(name:String):void // accessor function
{
this.name = name;
}
public function get fname():String // accessor function
{
return name;
}

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy