|
|
<?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.events.Event;import flash.events.DataEvent;import mx.messaging.ChannelSet;import mx.messaging.channels.AMFChannel;import mx.rpc.events.ResultEvent;private var fileRef:FileReference = new FileReference();private var docRef:DocumentReference = new DocumentReference();private var parentResourcePath:String = "/";private var serverPort:String = "servername:8080";// Set up channel set to talk to LiveCycle.// This must be done before calling any service or process, but only once for the entire application.// Note that this uses runtime configuration to configure the destination correctly, so// no other setup is needed in remoting-config.xml.private function initializeChannelSet():void {var cs:ChannelSet= new ChannelSet();cs.addChannel(new AMFChannel("remoting-amf", "http://" + serverPort + "/remoting/messagebroker/amf"));repositoryService.setCredentials("administrator", "password");repositoryService.channelSet = cs;}// Call this method to upload the file to be added to the repository.// This creates a file picker and lets the user select the file to upload.private function uploadFile():void {fileRef.addEventListener(Event.SELECT, selectHandler);fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,completeHandler);fileRef.browse();}// Gets called for selected file. Does the actual upload via our file upload servlet.private function selectHandler(event:Event):void {var request:URLRequest = new URLRequest("http://" + serverPort + "/remoting/lcfileupload");fileRef.upload(request);}// Called once the file is completely uploaded. Now it is safe to access that object for other things.private function completeHandler(event:DataEvent):void {var params:Object = new Object();docRef.url = event.data as String;docRef.referenceType=DocumentReference.REF_TYPE_URL;// At this point we can do whatever we want with the file that has been uploaded.// Our docRef variable has the object. Refer to the asdoc for DocumentReference for methods and properties.// Note that the url is publicly accessible at this point. Useful for testing purposes.writeResource();}// Uses RepositoryService API to write resource to repository. Sets the name to "resource.xdp" right now.// Note that the destination name of the RemoteObject below is the Endpoint name in the adminui.private function writeResource():void {var resource:Object = new Object();var content:Object = new Object();// define resourceresource.name = "resource.xdp";content.dataDocument = docRef;content.mimeType = "application/vnd.adobe.xdp+xml";resource.content = content;resource.description = "An XDP File";// call to remote objectrepositoryService.writeResource({"parentResourcePath":parentResourcePath,"resource":resource});}private function resultHandler(event:ResultEvent):void {// Do anything else here.}]]></mx:Script><mx:RemoteObject id="repositoryService" destination="RepositoryService" result="resultHandler(event);"/><mx:Panel id="lcPanel" title="Repository Service 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. This example automatically uploads it to the repository."/><mx:Button label="Select and Upload" click="uploadFile()" /></mx:Panel></mx:Application>
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/quickStarts_Invocation.3.8.html