Adobe COLDFUSION 9 Manual page 640

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
• If you call the
SaveUpdate
the record. The method updates an existing record only if the primary key exists in the client database.
• After you fetch data from the server, use only the
data into client side database. If you use the Save function to store the fetched data, the data is marked for insert on
server on commit, and the data you just got is written back to the server. In this case, a conflict occurs for the server
database primary key. If the server-side logic handles this conflict by ignoring the primary key ID from the client,
and lets the server generate a new ID, then the records are inserted, resulting in multiple copies of the data with
different IDs.
• For AIR integration offline support, if you do not globally declare the variables for client side ActionScript classes
but attempt to save the data records fetched from server using
session.saveUpdateCache()
following:
"Error: The object of type Object does not have the Entity metadata tag at
coldfusion.air::EntityCache/addMetadata()[D:\p4\depot\ColdFusion\cf_main\tools\AIRIntegrat
ion\OfflineSupport\src\coldfusion\air\EntityCache.as:228]"
Sending data to the server
The client SyncManager object tracks all the changes to the local data that happens through the session, so that the
local data and server data can be synchronized. The SyncManager also tracks the old data instances when data that is
already on the server is updated locally.
When the AIR application calls the
the CFC sync function. The sync function determines if there are any conflicts between the returned information. If
there are no conflicts, it updates the server data source. Otherwise, it handles the data as described in
management" on page 635.
Note: When you call the session.commit method, if the server does not throw an error, the commit method dispatches a
CommitSucces event. This event indicates that the session.commit method has executed successfully, and the client data
has been handed to the server CFC sync method. (If an error occurs while sending data to the sync method, the client
receives a CommitFault event.) Therefore, the CommitSucces event does not mean that the server has saved the client
data, but only that it has received the data. For example, the server does not save the data if there is a conflict, but the
CommitSucces event is still dispatched. You handle conflicts separately by adding an event listener on the SyncManager.
The event Flow is the first to get the CommitSucces event, and then a ConflictEvent event.
Setting Remote Credentials for SyncManager
To authenticate the AIR client that is connecting to the ColdFusion server, you can send the remoting credentials,
which can be used on the server side under the
a normal flash remoting object.
The following code contains the getRemoteObject() method in SyncManager, which gets the underlying flash
remoting object, so that you have full and same control over this as a normal flash remoting object.
syncmanager.getRemoteObject().SetRemoteCredentials("username","password");
Conflict management
Conflicts can happen in an offline application when the client modifies data that is already modified on the server. To
identify such a conflict, the session.Commit method passes the following data to the ColdFusion server sync method:
: An array of operations to perform INSERT, UPDATE, or DELETE.
operations
: An array of new data changes.
clientobjects
Method and a record with the specified primary key doesn't exist, the function inserts
SaveCache
, you might encounter AIR side error stackstrace with a message similar to the
method, all changes that happened on the session are passed to
Session.commit
tag. This is the same as setting the remoting credential for
<cflogin>
Last updated 8/5/2010
and
methods to save the fetched
SaveCacheUpdate
or
session.saveCache()
635
"Conflict

Advertisement

Table of Contents
loading

Table of Contents