The following Flex code example invokes a short-lived process named EncryptDocument. (See Invoking LiveCycle ES Using LiveCycle Remoting.)<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"creationComplete="initializeChannelSet();"><mx:Script><![CDATA[import mx.rpc.livecycle.DocumentReference;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;// Classes used in file retrievalprivate var fileRef:FileReference = new FileReference();private var docRef:DocumentReference = new DocumentReference();private var parentResourcePath:String = "/";private var serverPort:String = "localhost:8080";private var now1:Date;// Holds information returned from LiveCycle ES[Bindable]public var progressList:ArrayCollection = new ArrayCollection();// Set up channel set to invoke LiveCycle ES.// This must be done before calling any service or process, but only// once for the entire application.private function initializeChannelSet():void {var cs:ChannelSet= new ChannelSet();cs.addChannel(new AMFChannel("remoting-amf", "http://" + serverPort + "/remoting/messagebroker/amf"));EncryptDocument.setCredentials("administrator", "password");EncryptDocument.channelSet = cs;}// Call this method to upload the file.// This creates a file picker and lets the user select a PDF file to pass to the EncryptDocument process.private function uploadFile():void {fileRef.addEventListener(Event.SELECT, selectHandler);fileRef.browse();}// Gets called for selected file. Does the actual upload via the file upload servlet.private function selectHandler(event:Event):void {var request:URLRequest = new URLRequest("http://" + serverPort + "/remoting/lcfileupload");fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,completeHandler);fileRef.upload(request);}// Called once the file is completely uploaded.private function completeHandler(event:DataEvent):void {now1 = new Date();// Set the docRef’s url and referenceType parametersdocRef.url = event.data as String;docRef.referenceType=DocumentReference.REF_TYPE_URL;executeInvokeProcess();}//This method invokes the EncryptDocument processpublic function executeInvokeProcess():void {//Create an Object to store the input value for the EncryptDocument processvar params:Object = new Object();params["inDoc"]=docRef;// Invoke the EncryptDocument processvar token:AsyncToken;token = EncryptDocument.invoke(params);token.name = name;}// This method handles a successful conversion invocationpublic function handleResult(event:ResultEvent):void{//Retrieve information returned from the service invocationvar token:AsyncToken = event.token;var res:Object = event.result;var dr:DocumentReference = res["outDoc"] as DocumentReference;var now2:Date = new Date();// These fields map to columns in the DataGridvar progObject:Object = new Object();progObject.filename = token.name;progObject.timing = (now2.time - now1.time).toString();progObject.state = "Success";progObject.link = "<a href=’" + dr.url + "’> open </a>";progressList.addItem(progObject);}private function resultHandler(event:ResultEvent):void {// Do anything else here.}]]></mx:Script><mx:RemoteObject id="EncryptDocument" destination="EncryptDocument" result="resultHandler(event);"><mx:method name="invoke" result="handleResult(event)"/></mx:RemoteObject><!--//This consists of what is displayed on the webpage--><mx:Panel id="lcPanel" title="EncryptDocument LiveCycle Remoting Example"height="25%" width="25%" paddingTop="10" paddingLeft="10" paddingRight="10"paddingBottom="10"><mx:Label width="100%" color="blue"text="Select a PDF file to pass to the EncryptDocument process"/><mx:DataGrid x="10" y="0" width="500" id="idProgress" editable="false"dataProvider="{progressList}" height="231" selectable="false" ><mx:columns><mx:DataGridColumn headerText="Filename" width="200" dataField="filename" editable="false"/><mx:DataGridColumn headerText="State" width="75" dataField="state" editable="false"/><mx:DataGridColumn headerText="Timing" width="75" dataField="timing" editable="false"/><mx:DataGridColumn headerText="Click to Open" dataField="link" editable="false" ><mx:itemRenderer><mx:Component><mx:Text x="0" y="0" width="100%" htmlText="{data.link}"/></mx:Component></mx:itemRenderer></mx:DataGridColumn></mx:columns></mx:DataGrid><mx:Button label="Select File" click="uploadFile()" /></mx:Panel></mx:Application>
| 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/000011.html