The following code example invokes the Customer service
and creates a new customer. When you run this code example, ensure
that you fill out all text boxes. Also, ensure that you create the
Customer.as file that maps to com.adobe.livecycle.sample.customer.Customer.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#B1ABAB">
<mx:Script>
<![CDATA[
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.DataEvent;
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import mx.rpc.AsyncToken;
import mx.managers.CursorManager;
import mx.rpc.remoting.mxml.RemoteObject;
// Custom class that corresponds to an input to the
// LiveCycle ES encryption method
import customer.Customer;
// Classes used in file retrieval
private var fileRef:FileReference = new FileReference();
private var parentResourcePath:String = "/";
private var serverPort:String = "hiro-xp:8080";
private var now1:Date;
private var fileName:String;
// Prepares parameters for encryptPDFUsingPassword method call
public function executeCreateCustomer():void
{
var cs:ChannelSet= new ChannelSet();
cs.addChannel(new AMFChannel("remoting-amf", "http://" + serverPort + "/remoting/messagebroker/amf"));
customerService.setCredentials("administrator", "password");
customerService.channelSet = cs;
//Create a Customer object required to invoke the Customer service's
//createCustomer operation
var myCust:Customer = new Customer();
//Get values from the user of the Flex application
var fullName:String = txtFirst.text +" "+txtLast.text ;
var Phone:String = txtPhone.text;
var Street:String = txtStreet.text;
var State:String = txtState.text;
var Zip:int = parseInt(txtZIP.text);
var City:String = txtCity.text;
//Populate Customer fields
myCust.name = fullName;
myCust.phone = Phone;
myCust.street= Street;
myCust.state= State;
myCust.zip = Zip;
myCust.city = City;
//Invoke the Customer service's createCustomer operation
var params:Object = new Object();
params["inCustomer"]=myCust;
var token:AsyncToken;
token = customerService.createCustomer(params);
token.name = name;
}
private function handleResult(event:ResultEvent):void
{
// Retrieve the information returned from the service invocation
var token:AsyncToken = event.token;
var res:Object = event.result;
var custId:String = res["CustomerId"] as String;
//Assign to the custId to the text box
txtCustId.text = custId;
}
private function resultHandler(event:ResultEvent):void
{
}
]]>
</mx:Script>
<mx:RemoteObject id="customerService" destination="CustomerService" result="resultHandler(event);">
<mx:method name="createCustomer" result="handleResult(event)"/>
</mx:RemoteObject>
<mx:Style source="../bank.css"/>
<mx:Grid>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="New Customer" fontSize="16" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="First Name:" fontSize="12" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput styleName="textField" id="txtFirst"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Button label="Create Customer" id="btnCreateCustomer" click="executeCreateCustomer()"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="Last Name" fontSize="12" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput styleName="textField" id="txtLast"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="Phone" fontSize="12" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput styleName="textField" id="txtPhone"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="Street" fontSize="12" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput styleName="textField" id="txtStreet"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="State" fontSize="12" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput styleName="textField" id="txtState"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="ZIP" fontSize="12" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput styleName="textField" id="txtZIP"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="City" fontSize="12" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput styleName="textField" id="txtCity"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label text="Customer Identifier" fontSize="12" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:TextInput styleName="textField" id="txtCustId" editable="false"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:Application>
Style sheet
This quick start contains a style sheet named bank.css.
The following code represents the style sheet that is used.
/* CSS file */
global
{
backgroundGradientAlphas: 1.0, 1.0;
backgroundGradientColors: #525152,#525152;
borderColor: #424444;
verticalAlign: middle;
color: #FFFFFF;
font-size:12;
font-weight:normal;
}
ApplicationControlBar
{
fillAlphas: 1.0, 1.0;
fillColors: #393839, #393839;
}
.textField
{
backgroundColor: #393839;
background-disabled-color: #636563;
}
.button
{
fillColors: #636563, #424242;
}
.dropdownMenu
{
backgroundColor: #DDDDDD;
fillColors: #636563, #393839;
alternatingItemColors: #888888, #999999;
}
.questionLabel
{
}
ToolTip
{
backgroundColor: black;
backgroundAlpha: 1.0;
cornerRadius: 0;
color: white;
}
DateChooser
{
cornerRadius: 0; /* pixels */
headerColors: black, black;
borderColor: black;
themeColor: black;
todayColor: red;
todayStyleName: myTodayStyleName;
headerStyleName: myHeaderStyleName;
weekDayStyleName: myWeekDayStyleName;
dropShadowEnabled: true;
}
.myTodayStyleName
{
color: white;
}
.myWeekDayStyleName
{
fontWeight: normal;
}
.myHeaderStyleName
{
color: red;
fontSize: 16;
fontWeight: bold;
}