Wednesday, November 2, 2011

Resources not appearing in workbench

If you are putting resources in the LC repository through the SDK, you'll notice that they don't appear in workbench. You can confirm that they are truly there by going to the address http://server:port/repository, and then to actually get the resource to appear in workbench follow these steps:

1 import com.adobe.repository.infomodel.bean.ResourceProperty; 
    import java.util.Collection;

2. Use: Resource newResource = (Resource) infomodelFactory.newResource (not Resource newResource = (Resource) infomodelFactory.newImage(...) )

3. Add the following lines of code:
ResourceProperty rProperty=new ResourceProperty();
rProperty.setNamespace("System");
rProperty.setName("PRIMARY");
rProperty.setValue(“true”);
Collection rProperties=newResource.getResourceProperties();
rProperties.add(rProperty);

Friday, June 3, 2011

PDF to email friendly HTML

There is a service in LiveCycle to convert PDF files to HTML, and it the output looks pretty decent, but after looking at the html code, we realized that there were a bunch of DIVS and such that were added to the forms. This didn't work out to great as a solution for us, because we planned to place that html into an email, and with all the divs and such it would look horrible (since some email clients don't follow a standard). There were a few options in the service to try and manipulate the CSS and such, but nothing that gave a satisfactory result.


We noticed that when converting xdp to html, the best way to maintain structure was by using tables. Subforms convert to divs, however email clients do not always render divs properly, so we stuck to using tables to structure our forms and also to control the layout of our forms. However, the layout got messed up when we did the conversion, so the solution that we came up with was to use the renderHTMLForm service with the option of nostyles, and to add the styles in manually.
Essentially we noticed that all of the names of complex objects (objects containing other objects, ie subforms, tables, table rows) that we created in the form would be carried over into the created html, with some additions.

So if we have a table called Details, which was in a a subform called Content, it would be converted to a table with id=NContent_0.NDetails_0.

I'm not sure what the "N" denotes, but the 0 at the end is the index of the object, so if you have repeating elements, the index would be noted at the end.

At this point, ideally, we would have liked to user the renderHTMLForms to import a css file in to use,  but it puts the styles inbetween the head tags, which again is not great for email clients. So instead we wrote a custom component to insert it the styles from the css to inline (there are lots of libraries to convert css to inline, sorry wouldn't be able to tell you which).

The issue at this point was to know where to put the styles. Thats where the ids come in and why we used tables to structure the form. We were able to style the different parts of the form by placing them in the tags, matching them up with the appropriate id's. We used a config file to map the styles to the id's to try and automate and reuse as much as possible.

Not as elegant as i would like, but unfortunately the only way that i could think of to resolve the issue.

Tuesday, April 26, 2011

Eclipse - "Failed to start the Java Virtual Machine"

I recently had downloaded Eclipse onto my new work laptop and had issues with getting it started. The splash screen would come up and then a dialog reading "Failed to start the Java Virtual Machine" would pop up.

Again, google comes to the rescue and lets me know that the java version is not explicitly specified by default, and you could do so in the workbench.ini file by using -vm. My ini file looks a bit like this now;

--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
C:\Program Files\Java\jre6\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx512m
I was able to get this and other information from http://wiki.eclipse.org/Eclipse.ini

Wednesday, March 9, 2011

Importing a LiveCycle ES process into LiveCycle ES2

Back in july I had a blog posting about moving LiveCycle ES 8.2 processes to an ES2 environment, found here. Since then, Adobe has put up a new tool in their Labs that that will install as a plugin to Workbench. With this archive migration tool installed, LiveCycle Workbench ES2(SP1) users can import a LiveCycle 8.x archive into the Workbench workspace directly to take advantage of the new features available in ES2. A new LiveCycle ES2 application is created and all the resources in the 8.x archive are imported into the ES2 application.
The new tool can be found at http://labs.adobe.com/technologies/lcworkbench_archivemigration/

Inferring an XSD from XML

When working with forms in LiveCycle, it is important to know the structure of the XML data that gets exported from the form and passed around the LiveCycle process. In ES2 Adobe has introduced the ability to create and use an Adobe Data Model to describe the structure. Workbench has a tool which will allow you to to create these models and Adobe is really trying to encourage developers to use it more, not just in LiveCycle development, but also in enterprise level development with Flex and Java.
However, being old school, I still found it more comfortable to use an XML schema file (.xsd) to describe the structure of the data in the form and to use in a LiveCycle process to be able to access the separate fields in a form.
Creating an XSD can be troublesome, creating it from scratch even more so. The easiest method to create the XSD file is by inferring it from an XML file. There are many XML editors that are able to do this, a few being:
Unfortunately you have to pay for these software. There are a few free options out there, my favorite being Trang. Its a small and simple command line tool that works in multiple platforms. The way to use it is to
  1. Download Trang. You can download Trang at http://www.thaiopensource.com/relaxng/trang.html
  2. Extract the files from the zipped download
  3. Run the command passing your input XML file (it can be multiple XML files) and specifying the result XSD file.
The syntax of the command should look like;
java -jar trang.jar input.xml input2.xml input3.xml output.xsd
And its as simple as that! You have your XSD file that you can use in your form and in your process to describe the structure of the data.