Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 647

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 savesuccess(event:SessionResultEvent):void
{
Alert.show("Customer was Inserted Successfully");
// Load some otehr Customer(ex: id=11) so that we can perform Update on
that Customer
var loadtoken:SessionToken =session.loadByPK(Customer,{cid:11});
loadtoken.addResponder(new mx.rpc.Responder(loadCustomer,loadFault))
}
private function loadCustomer(event:SessionResultEvent):void
{
var cus1:Customer = event.result as Customer;
cus1.name = "UpdateCustomerName";
var add1:Address = new Address;
add1.aid = 22;
add1.street = 'UpdatedCustomerAddress';
cus1.address = add1;
/*
Let's call update now and save it to Client side SQLite DB
*/
var savetoken:SessionToken = session.update(cus1);
savetoken.addResponder(new mx.rpc.Responder(updateSuccess,updatefualt));
}
private function updateSuccess(event:SessionResultEvent):void
{
Alert.show("Customer was updated Successfully");
/*
Let's Load another Customer(for example, with id 128) to perform a Delete operation on that
*/
var loadtoken:SessionToken = session.loadByPK(Customer,{cid:128});
loadtoken.addResponder(new mx.rpc.Responder(loadCustomerForDelete,loadFault));
}
private function loadCustomerForDelete(event:SessionResultEvent):void
{
// pass the loaded customer to remove function
var removetoken:SessionToken = session.remove(event.result);
removetoken.addResponder(new mx.rpc.Responder(removeSuccess,removeFault));
}
private function removeSuccess(event:SessionResultEvent):void
{
Alert.show("Customer was deleted Successfully");
}
private function commit():void
{
/*
Until now, you have performed Insert/Update/Delete operation on Customer/Address
entities on the client side SQLite DB. Now use the Commit opertaion to
send them to the Server.
*/
var committoken:SessionToken = session.commit();
committoken.addResponder(new mx.rpc.Responder(commitSuccess, commitFault));
}
private function commitSuccess(event:SessionResultEvent):void
{
Last updated 1/20/2012
642

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents