Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 632

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
• In case of a conflict, the
sync
four properties a conflict object can have:
The
property of the conflict object must be a user-defined CFC type that represents the server-side
serverobject
database table. The following example generates a conflict object with a valid ServerObject property of type
employee.cfc, which represents the Employee table:
<cfset serverobject = EntityLoadByPK("employee",originalobject.getId())>
<cfset conflict = CreateObject("component","CFIDE.AIR.conflict")>
<cfset conflict.serverobject = serverobject>
<cfset conflict.clientobject = clientobject>
<cfset conflict.originalobject = originalobject>
<cfset conflict.operation = operation>
<cfset conflicts[conflictcount++] = conflict>
<cfreturn conflicts>
If you are using ColdFusion ORM, you can replace the preceding example with the following code.
<cfset conflict = CreateObject("component","CFIDE.AIR.Conflict")
<cfset serverobject = EntityLoadByPK("employee",#res.IDENTITYCOL#)>
<cfset conflict.SetServerobject(serverobject)>
• When an AIR client with stale data tries to update an already deleted record from the database, server throws the
conflict, and the client's conflict handle, which has the
accepts the changes from the server. However, the client method does not delete the stale record, which no longer
exists in the server database, from the client database.
To prevent this issue: The serverObject property of the conflict object returned by the server must be null, if the
record that the client requests for updating is no longer in the database. For example:
<cfset serverobject = EntityLoadByPK("employee",originalobject.getId())>
<!----If the operation is INSERT, serverObject is also NULL.hence NEQ condition---->
<cfif not isdefined('serverobject') and operation NEQ "INSERT" >
<cflog text="CONFLICT::SERVER OBJECT NOT FOUND, RECORD MAY BE DELETED ALREADY">
<cfset conflict = CreateObject("component","CFIDE.AIR.conflict")>
<cfset conflict.clientobject = clientobject>
<cfset conflict.originalobject = originalobject>
<cfset conflict.operation = operation>
<cfset conflicts[conflictcount++] = conflict>
<cfcontinue>
</cfif>
Offline AIR application code constructs
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:
function returns an array of
,
operation
serverobject
KeepAllServerObjects
Last updated 1/20/2012
objects to the client. There are
"CFIDE.AIR.Conflict"
,
,
clientobject
originalobject
or
KeepServerObject
627
.
method

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents