Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 645

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
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplic ation xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.AsyncToken;
import mx.controls.Alert;
import coldfusion.air.events.*;
import coldfusion.air.*;
import onetoone.Address;
import onetoone.Customer;
private var session:Session;
private var dbFile:File;
private var cusColl:ArrayCollection;
private var syncmanager:SyncManager;
private var add:Address;//global variable for address.as
private var cus:Customer; //global variable for customer.as
private function init():void
{
// Provide Credentials for Server side Connection and CFC
syncmanager = new SyncManager();
syncmanager.cfPort = 80;
syncmanager.cfServer = "localhost";
// Path of the Server side CFC from CF webroot
syncmanager.syncCFC = "AIRIntegration.cusManager";
// This handler is called when any conflict occurs while
writing back changes on the server side
syncmanager.addEventListener(ConflictEvent.CONFLICT, conflictHandler);
// Fetch Server side DB data onto Client SQLite DB while
starting the App
var token:AsyncToken= syncmanager.fetch("fetch");
token.addResponder(new mx.rpc.Responder(fetchSuccess, fetchFault));
}
private function conflictHandler(event:ConflictEvent):void
{
Alert.show("conflict man!");
var conflicts:ArrayCollection = event.result as ArrayCollection;
// Accept Server data and write it to client side SQLite DB
var token:SessionToken
= session.keepAllServerObjects(conflicts);
token.addResponder(new
mx.rpc.Responder(conflictSuccess, conflictFault));
}
private function conflictSuccess(event:SessionResultEvent):void
{
Alert.show("conflict resolved");
}
Last updated 1/20/2012
640

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents