Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 631

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
To manage interactions with the AIR application and keep the data synchronized, ColdFusion application uses a
component called the SyncManager. The SyncManager implements the CFIDE.AIR.ISyncManager interface. The
component has two functions:
• A
function that the AIR application calls to get data from ColdFusion. This function is not part of the
fetch
ISyncManager interface, but is required. The function can have any arbitrary name, but is called
convention.
• A sync function that the AIR application calls to synchronize the ColdFusion and AIR data sources when the
application updates or changes data. This function takes three parameters:
An array of operations to perform INSERT, UPDATE, or DELETE.
operations
An array of objects, where each item in the array represents the client's current view of the data
clientObjects
to be synchronized.
An array of objects, each item in this Array represents the corresponding original data from the
originalObjects
server (if any), such as an existing employee record that a user is updating. For an INSERT operation, this object is
null. For a DELETE operation, this object is normally the same as the current data.
Incase of Conflict during Sync process, the sync function returns to the AIR client an Array of
"CFIDE.AIR.Conflict.cfc" objects. Each of this Conflict object consists of a single serverObject element. The sync
function sets the element to equal the server copy of the record that is in conflict. The client application can then handle
the conflict as described in
"Conflict
Server-Side notes
• When the
function performs a DELETE operation, it gets the primary key ID from the OriginalObject of the
sync
Sync method, as the ClientObject is NULL. For update and insert operations, use the ClientObject key value.
• When you do an INSERT operation, the CFC checks whether the OriginalObject parameter of the sync method is
a simple value, as in the following code:
{NOT IsSimpleValue(OriginalObject)}
• In an INSERT operation, OriginalObject passed to the Sync function is null. So if you attempt to retrieve any of its
properties, you get a Method NOT Found error. For Example, OriginalObject.GetID results in a Method GetID()
not found error. So, for Insert operation, use ClientObject to access various fields.
• While a ColdFusion application can use cfquery to directly manage the database, most AIR applications are
expected to use the ORM feature. The discussion here uses ColdFusion ORM for server-side data management.
• You may see the following kind of error message if you are using ColdFusion 8 Remoting with AIR offline
applications, which have server side "
Error handling message: flex.messaging.MessageException: Unable to invoke CFC - a different
object with the same identifier value was already associated with the session: [address#1].
Root cause:org.hibernate.NonUniqueObjectException: a different object with the same
identifier value was already associated with the session: [address#1]
You may also encounter this error with ColdFusion 9 Remoting but only for
To resolve this sort of error, call your
<cfif operation eq "INSERT" OR operation eq "UPDATE">
<cfset obj = ORMGetSession().merge(clientobject)>
<cfset EntitySave(obj)>
<cfelseif operation eq "DELETE">
<cfset obj = ORMGetSession().merge(originalobject)>
<cfset EntityDelete(obj)>
</cfif>
management" on page 635.
" method using ORM
Sync
/
EntitySave
EntityDelete
Last updated 1/20/2012
/
EntitySave()
EntityDelete()
EntityDelete
method in following way in "
626
by
fetch
methods.
method.
" method.
Sync

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents