Adobe LiveCycle Content Services software lets building content-rich engagement applications rapidly with running on Adobe LiveCycle Enterprise Suite (ES) platform. As LiveCycle ES provides efficient solutions for media-centric domains, Content Services is a one of the most important modules with the reason that it has management capabilities for document based contents. The main advantage of using Adobe LiveCycle platform is that accelarating solution’s time to market. So, the motivation of this work is to see that how easy and fast is that developing a client application to interact with Adobe LiveCycle Content Services module.

The performance concept is also another issue that should be taken into accout at client application side. Flex is one of the best option with the reason of using AMF (Action Messaging Format), which offers fast and efficient communication  with help of binary format. There is another important reason that LiveCycle Service Discovery Plug-in is available to find and generate any service resource at the client application. Let’s take a look at Flex solution provided below for the scenario that retrieving the contents stored and managed by Content Services software.

-          Install LiveCycle Service Discovery Plug-in for Flash Builder

You can find the details here

-          Find and define DocumentManagementService in the LiveCycle services list

Once connecting to LiveCycle ES data services, then you will be able to search service list

<fx:Declarations>
    <services:DocumentManagementService fault="documentService_faultHandler(event)" result="documentService_resultHandler(event)"/>
</fx:Declarations>

-          Test and call getSpaceContents method

The method is available under DocumentManagementService definition, and it can be tested via Test Operation tool inside Flash Builder

private function retrieveContentsAction():void {
	documentService.getSpaceContents(storeLoc.text,spaceLoc.text, false);
}
Testing getSpaceContents method with Test Operation Tool

Testing getSpaceContents method with Test Operation Tool

-          Bind result to a datagrid component

The result is returned as a list of retrieved contents and a datagrid component can be used to visualize those contents. In the example, I have created an auxiliary class named ContentInstance to format the result list.

protected function documentService_faultHandler(event:FaultEvent):void{
	Alert.show(event.fault.toString());
}

protected function documentService_resultHandler(event:ResultEvent):void{
   var returnObj:ArrayCollection = event.result as ArrayCollection;
   productList = new ArrayCollection();
   for(var i:int=0; i<returnObj.length; i++){
	   var atmapObj:Object = returnObj[i]["attributeMap"] as Object;
	   var docObj:Object = returnObj[i]["document"] as Object;
	   var ci:ContentInstance = new ContentInstance();
	   ci.guid = atmapObj["{http://www.alfresco.org/model/system/1.0}node-uuid"] as String;
	   ci.documentName = atmapObj["{http://www.alfresco.org/model/content/1.0}name"] as String;
	   ci.documentCreator = atmapObj["{http://www.alfresco.org/model/content/1.0}creator"] as String;
	   //ci.documentLink = atmapObj["{http://www.alfresco.org/model/content/1.0}browse-link"] as String;
	   ci.documentLink = docObj["url"] as String;
	   productList.addItem(ci);

	}
}
Display contents in Datagrid component

Display contents in Datagrid component

I think anybody tries to develop the same will aggree with me on that it is very easy and fast to develop an application running on LiveCycle ES platform by using Flex. Especially, testing and defining a service with help of service discovery plug-in makes application development and unit testing of LiveCycle’s services really exciting.

LiveCycle Enterprise Suite provides capabilites and services for developing easily a client application especially by using Flex. In our case, LiveCycle Content Services module has been installed and then contents, each of which is a PDF document, are needed to be uploaded to the content space. Briefly the usage scenario is that an user is only responsible for uploading original document and the another user is responsible to view the document content and add metadata information for it. At Content Services module side, we have developed a custom content model and alfresco application module package(AMP) for handling domain specific metadata information. At user side, we have developed a client application with Flex 4 by using remote services of LiveCycle server.

Rendering PDF in Flex Client

Rendering PDF in Flex Client

The main problem with Flex client application was that displaying PDF document in a popup window. I have read almost every articles about displaying PDF in Flex application and then I realized that the best way to achieve the same is using google’s iframe component. But, the problem about iframe was that it crashes once direct URL of PDF document is assigned as its source. So as required in the usage scenario, PDF documents are the contents stored in the system and they should be viewed directly. Generally, the solution is that using a temprorary HTML, which gets rendered to initialize Iframe instance, and then the direct URL of PDF can be provided as its source. Please find the solution’s detail below.

- Define an IFrame instance in Flex by making it disabled.

<flexiframe:IFrame id="iframe" source="docViewer.html" backgroundColor="gray" width="100%" height="100%" visible="false"/>

- Generate an HTML resource by including only a couple of mandatory HTML tags

<html>
    <body>
    <h1>Creasis - HTML Test</h1>
   </body>
</html>

- Develop a popup window function to display IFrame instance

private function showDocumentAction(doclink:String):void {
	var showContDoc:DocumentViewer=DocumentViewer(PopUpManager.createPopUp(
		this, DocumentViewer , true) as spark.components.TitleWindow);
	showContDoc.addElement(outerDocument.iframe);
	outerDocument.iframe.visible = true;
	outerDocument.iframe.source = doclink
}

<s:Button label="Show Doc" width="75" click="showDocumentAction(data.documentLink)"/>

As you can easily see that, temprorary HTML resource is just used to help rendering IFrame instance. So the solution can be thought as ineffecient one and it will be invalid once the IFrame is improved for displaying PDF’s URL directly. I also aggree with the idea that IFrame should not be used for displaying a document within Flex application. To overcome such problems, AIR based client application should be considered seriously.