API Quick Starts (Code Examples) > Invocation API Quick Starts > Quick Start: Invoking a long-lived process using LiveCycle Remoting

Quick Start: Invoking a long-lived process using LiveCycle Remoting
The following MXML code example invokes the MortgageLoan - Prebuilt process by passing XML data that represents a user’s mortgage information. (See Invoking Human-Centric Long-Lived Processes.)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" creationPolicy="all"
   backgroundGradientColors="[#FFFFFF, #FFFFFF]">
 
   <mx:Script>
      <![CDATA[
 
         import mx.controls.Alert;
         import mx.rpc.events.FaultEvent;
         import mx.rpc.events.ResultEvent;
         import flash.net.navigateToURL;
         import mx.messaging.ChannelSet;
         import mx.messaging.channels.AMFChannel;
         import mx.collections.ArrayCollection;
         import mx.rpc.livecycle.JobId;
         import mx.rpc.livecycle.JobStatus;
         import mx.rpc.livecycle.DocumentReference;
         import mx.formatters.NumberFormatter;
         
         // Holds the job ID returned by LC.JobManager
         private var ji:JobId;  
 
        private function submitApplication():void
         {
 		//Invoke the MortgageLoan - Prebuilt process 	
         var cs:ChannelSet= new ChannelSet(); 
   		  cs.addChannel(new AMFChannel("remoting-amf", "http://localhost:8080/remoting/messagebroker/amf")); 
          LC_MortgageApp.setCredentials("administrator", "password");
          LC_MortgageApp.channelSet = cs;
         
         //Get the XML data to pass to the LiveCycle ES process
         var xml:XML = createXML();
         var params:Object = new Object();
    	 params["xmlFormData"]=xml;
         LC_MortgageApp.invoke_Async(params);
         }
 
         // Handles async call that invokes the long-lived process
         private function resultHandler(event:ResultEvent):void
         {
            ji = event.result as JobId;
            jobStatusDisplay.text = "Job Status ID: " + ji.jobId as String; 
         }
 
         private function createXML():XML
         {
            //Calculate the Mortgage value to place in the XML data
            var propertyPrice:String = txtPropertyPrice.text ; 
            var downPayment:String = txtDownPayment.text ; 
            
            var intPropertyPrice:int = int(propertyPrice);
 			var intDownPayment:int = int(downPayment);
 			
 			var intMortgage:int = intPropertyPrice-intDownPayment;
 			var numFormatter:NumberFormatter = new NumberFormatter();
 			numFormatter.precision = 2; 
 	            
            var model:XML = 
 
               <MortgageApp>
               <MortgageFields>
               		<PropertyPrice>{propertyPrice}</PropertyPrice>
               		<DownPayment>{downPayment}</DownPayment>
               		<Mortgage>{intMortgage}</Mortgage> 
               		<Term>{termDropDown.text}</Term>
               		<InterestRate>{termRate.text}</InterestRate>
               </MortgageFields>
               <ApplicantFields>
                  	 <LastName>{txtLastName.text}</LastName>	
                     <FirstName>{txtFirstName.text}</FirstName>
                     <PhoneNumber>{txtPhone.text}</PhoneNumber>
                     <SSN>{txtSIN.text}</SSN>
               </ApplicantFields>
               </MortgageApp>
                  
          return model;
         }
        
        
      ]]>
   </mx:Script>
 
   <!-- <mx:Style source="main.css"/> -->
   <!-- Declare the RemoteObject and set its destination to the mortgage-app remoting endpoint defined in LiveCycle. -->
   <mx:RemoteObject id="LC_MortgageApp" destination="MortgageLoan - Prebuilt" result="resultHandler(event);">
      <mx:method name="invoke_Async" result="resultHandler(event)"/>
  </mx:RemoteObject>
   
   <mx:Panel title="My Mortgage Application" backgroundAlpha="0.8" backgroundImage="img/background.jpg">
 
             <mx:Grid>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
                  <mx:Label text="Last Name"/>
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
                  <mx:TextInput id="txtLastName"/>
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
                  <mx:Label text="First Name"/>
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
                  <mx:TextInput id="txtFirstName"/>
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
                  <mx:Label text="Phone Number"/>
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
                  <mx:TextInput id="txtPhone"/>
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
                  <mx:Label text="SIN NUmber"/>
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
                  <mx:TextInput id="txtSIN"/>
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
                  <mx:Label text="Property Price"/>
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
                  <mx:TextInput id="txtPropertyPrice"/>
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
                  <mx:Label text="Down Payment"/>
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
                  <mx:TextInput id="txtDownPayment"/>
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
                  <mx:Label text="Term"/>
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
               <mx:ComboBox width="100%" id="termDropDown">
				<mx:ArrayCollection>
            		<mx:Object label="5" data="5"/>
            		<mx:Object label="10" data="10"/>
            		<mx:Object label="20" data="20"/>
       			 </mx:ArrayCollection>
       			 </mx:ComboBox>
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
                 <mx:Label text="Interest Rate"/>
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
               <mx:ComboBox width="100%" id="termRate">
				<mx:ArrayCollection>
            		<mx:Object label="5.0" data="5.0"/>
            		<mx:Object label="5.5" data="5.5"/>
            		<mx:Object label="6.0" data="6.0"/>
       			 </mx:ArrayCollection>
       			 </mx:ComboBox>
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <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:GridItem>
               <mx:GridItem width="100%" height="100%">
               </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow width="100%" height="100%">
               <mx:GridItem width="100%" height="100%">
               </mx:GridItem>
               <mx:GridItem width="100%" height="100%">
               </mx:GridItem>
            </mx:GridRow>
         </mx:Grid>
   
      <mx:ControlBar bottom="20">
         <mx:Button label="Submit Application" click="submitApplication()"/>
      </mx:ControlBar>
      <mx:Text id="jobStatusDisplay" width="300" />
   </mx:Panel> 
</mx:Application>
 

API Quick Starts (Code Examples) > Invocation API Quick Starts > Quick Start: Invoking a long-lived process using LiveCycle Remoting

Programming with LiveCycle ES (LiveDocs)
Adobe LiveCycle ES Update 1

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/000007.html