Adobe COLDFUSION 9 Manual page 638

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

Advertisement

633
DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
private function init():void
{
syncmanager = new SyncManager();
//The ColdFusion server and port. Port without double quotes as it is
//expected to be integer and IP is taken as String.
syncmanager.cfPort = CFServerPort;
syncmanager.cfServer = "CFServerIP";
//The CFC that implements the ColdFusion sync manager. Here
//AIRIntegration is the user defined folder under webroot.
syncmanager.syncCFC = "AIRIntegration.empManager";
//Specify a user-defined CF destination,if not specified, default destination
//'ColdFusion' will be used
syncmanager.destination = 'USerDefinedCFDestination'
//The event listener for conflict events returned byt the CFC
syncmanager.addEventListener(ConflictEvent.CONFLICT, conflictHandler);
//The local database file
var dbFile:File = File.userDirectory.resolvePath("EmpManager.db");
//Create a session object, which handles all interactions between the
//AIR application and the SQLite database.
var sessiontoken:SessionToken = syncmanager.openSession(dbFile, 999);
//Add a responder for handling session connection results.
sessiontoken.addResponder(new mx.rpc.Responder(connectSuccess,
connectFault));
}
Fetching data from the server
Use the SyncManager fetch method to fetch data from the ColdFusion server by calling the fetch method of the server
data object. The
method takes the name of the CFC fetch method (typically fetch) as its first
syncManager.fetch
parameter, followed by any CFC fetch method parameters.
The
method returns an AsyncToken object that provides access to the data. The function
syncManager.fetch
returns the token synchronously. The ColdFusion CFC response returns asynchronously. Therefore, call the token's
addResponder method to specify a responder that handles the responses for successful and failed fetches.
To fetch the initial data from the server, you can include the following code in the Application
method.
init()
// fetch the data.
var token:AsyncToken = syncmanager.fetch("fetch");
//Specify the responder to handle the fetch results.
token.addResponder(new mx.rpc.Responder(fetchSuccess, fetchFault));
Managing the local database
You use a Session object to manage the data in the local SQLite database. You call the syncmanager.openSession
method to create a session with a specific database file. The method returns a SessionToken token, and the
SessionToken.session property provides access to the session. You use code in the token's openSessionSuccess
responder event handler to provide access to the session object. This way, you do not access the session, and therefore
the database, until it is successfully opened.
Last updated 8/5/2010

Advertisement

Table of Contents
loading

Table of Contents