Take a survey

Developing Applications Using APIs > Rendering Forms > Rendering Forms as HTML > Rendering a form as HTML using the Java API

Rendering a form as HTML using the Java API
To render an HTML form using the Java API, perform the following tasks:
1.
Include client JAR files, such as adobe-forms-client.jar, in your Java project’s class path. For information about the location of these files, see Including LiveCycle ES library files.
2.
Create a FormsServiceClient object by using its constructor and passing a ServiceClientFactory object that contains connection properties. For information, see Setting connection properties.
3.
Create an HTMLRenderSpec object by using its constructor.
To render an HTML form with a toolbar, invoke the HTMLRenderSpec object’s setHTMLToolbar method and pass an HTMLToolbar enum value. For example, to display a vertical HTML toolbar, pass HTMLToolbar.Vertical.
To set the locale value for the HTML form, invoke the HTMLRenderSpec object’s setLocale method and pass a string value that specifies the locale value, For information about locale values, see LiveCycle ES API References.
To render the HTML form within full HTML tags, invoke the HTMLRenderSpec object’s setOutputType method and pass OutputType.FullHTMLTags.
Note: Forms are not successfully rendered in HTML when the StandAlone option is true and the ApplicationWebRoot references a server other than the J2EE application server hosting LiveCycle ES (the ApplicationWebRoot value is specified using the URLSpec object that is passed to the FormsServiceClient object’s renderHTMLForm method). When the ApplicationWebRoot is another server from the one hosting LiveCycle ES, the value of the web root URI in the LiveCycle Administration Console needs to be set as the Form's web application URI value. This can be done by logging in to the LiveCycle Administration Console, clicking Services > LiveCycle Forms ES, and setting the Web Root URI as http://server-name:port/FormServer. Then, save your settings.
4.
Invoke the FormsServiceClient object’s renderHTMLForm method and pass the following values:
A string value that specifies the form design name, including the file name extension. If you are referencing a form design that is saved in the repository, ensure that you specify the / character before the file name.
A TransformTo enum value that specifies the HTML preference type. For example, to render an HTML form that is compatible with dynamic HTML for Internet Explorer 5.0 or later, specify TransformTo.MSDHTML.
A com.adobe.idp.Document object that contains data to merge with the form. If you do not want to merge data, then pass an empty com.adobe.idp.Document object. For information, see Prepopulating Dynamic Forms.
The HTMLRenderSpec object that stores HTML run-time options.
A string value that specifies the HTTP_USER_AGENT header value; for example, Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322).
A URLSpec object that stores URI values required to render an HTML form. For information, see Specify URI values.
A java.util.HashMap object that stores file attachments. This is an optional parameter and you can specify null if you do not want to attach files to the form. For information, see Attach files to the form.
The renderHTMLForm method returns a FormsResult object that contains a form data stream that must be written to the client web browser.
5.
Create a com.adobe.idp.Document object by invoking the FormsResult object ‘s getOutputContent method.
Get the content type of the com.adobe.idp.Document object by invoking its getContentType method.
Set the javax.servlet.http.HttpServletResponse object’s content type by invoking its setContentType method and passing the content type of the com.adobe.idp.Document object.
Create a javax.servlet.ServletOutputStream object used to write the form data stream to the client web browser by invoking the javax.servlet.http.HttpServletResponse object’s getOutputStream method.
Create a java.io.InputStream object by invoking the com.adobe.idp.Document object’s getInputStream method.
Create a byte array and allocate the size of the InputStream object. Invoke the InputStream object’s available method to obtain the size of the InputStream object.
Populate the byte array with the form data stream by invoking the InputStream object’s read method and passing the byte array as an argument.
Invoke the javax.servlet.ServletOutputStream object’s write method to send the form data stream to the client web browser. Pass the byte array to the write method.
View Quick Start

 

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/renderingHTML.38.9.html