
644
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
Alert.show("Commit Failed::"+event.error);
}
private function loadFault(event:SessionFaultEvent):void
{
Alert.show("Load Failed::"+event.error);
}
private function updatefualt(event:SessionFaultEvent):void
{
Alert.show("update fault"+event.error);
}
private function savefault(event:SessionFaultEvent):void
{
Alert.show("Save Fault::"+event.error);
}
]]>
</mx:Script>
<mx:Button click="commit()" name="commitbutton"
label="Commit/write local data to Server">
</mx:Button>
</mx:WindowedApplication>
Server-side code
Create the following cfc files - Application.cfc, Customer.cfc, Address.cfc, and Cusmanager.cfc with code like the
following. The AIR client interacts with the Cusmanager.cfc file, in which you specify the code to fetch and sync the
data back to the server.
Application.cfc
<cfcomponent>
<cfset this.name = "OneTonOneExample">
<cfset this.datasource="testorm">
<cfset this.ormenabled="true">
<cfset this.ormsettings={dialect = "MicrosoftSQLServer"}>
</cfcomponent>
Customer.cfc
<cfcomponent persistent="true">
<cfproperty name="cid" fieldtype="id" >
<cfproperty name="name" >
<cfproperty name="address" fieldType='one-to-one'
CFC="address" fkcolumn='aid' cascade='all' >
</cfcomponent>
Address.cfc
<cfcomponent persistent="true">
<cfproperty name="aid" fieldtype="id" >
<cfproperty name="street" >
</cfcomponent>