Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 646

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
private function fetchSuccess(event:SyncResultEvent):void
{
var cus:Array = event.result as Array;
cusColl = new ArrayCollection(cus);
// Open a Session for the client side SQLite DB
dbFile = File.userDirectory.resolvePath("onetoonesync.db");
var sessiontoken:SessionToken
=syncmanager.openSession(dbFile,017915);
sessiontoken.addResponder(new
mx.rpc.Responder(connectSuccess,connectFault));
}
private function connectSuccess(event:SessionResultEvent):void
{
session = event.sessionToken.session;
if(cusColl.length > 0)
{
// This operation saves it to the AIR SQLite DB
var savetoken:SessionToken
= session.saveCache(cusColl);
savetoken.addResponder(new
mx.rpc.Responder(saveCacheSuccess, savefault));
}
else
{
Alert.show("No data available from Server to save on local DB");
}
}
private function saveCacheSuccess(event:SessionResultEvent):void
{
Alert.show("Data saved on client Sqlite DB from Server");
/*
A new Insert is tried here. Note that this is not a complete user interface
application. Otherwise, typically, users need to provide inputs to populate
the Customer/Address Objects
*/
var cus:Customer = new Customer();
cus.cid=12;
cus.name="New Customer";
var add:Address = new Address();
add.aid = 14;
add.street = 'New Address';
cus.address = add;
/*
INSERT the new Records, this is first saved in client side SQLite DB.
On the Commit operation this new record is saved in the Server side DB
Notice that although you are saving the Customer object here,
this operation saves even the binded Address Object also,
as both the entities are CASCADED inside Customer Class
*/
var savetoken:SessionToken = session.save(cus);
savetoken.addResponder(new mx.rpc.Responder(savesuccess, savefault));
}
Last updated 1/20/2012
641

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents