Rendering HTML Forms Using Custom CSS Files rendering-html-forms-using-custom-css-files
Samples and examples in this document are only for AEM Forms on JEE environment.
The Forms service renders HTML forms in response to an HTTP request from a web browser. When rendering an HTML form, the Forms service can reference a custom CSS file. You can create a custom CSS file to meet your business requirements and reference that CSS file when using the Forms service to render HTML forms.
The Forms service silently parses the custom CSS file. That is, the Forms service does not report errors that may be encountered if the custom CSS file does not comply with CSS standards. In this situation, the Forms service ignores the style and continues with the remaining styles in the CSS file.
The following list specifies styles that are supported in a custom CSS file:
- Class level selector-style pairs: If present in a custom CSS file, selectors used in the HTML form as class styles are used. Unused class styles are ignored.
- Identifier level selector-style pairs: All identifier styles are used if they are used in the HTML form.
- Element level selector-style pairs: All element styles are used if they are used in the HTML form.
- Style Priority: Style priority (like important) is supported and can be used in a custom CSS file.
- Media Type: One or more selector-style pairs can be wrapped in @media style to define the media type. The Forms service does not check whether the specified media type is supported. The media type specified in the custom CSS file is merged in the HTML form.
You can retrieve a sample CSS file by using the FormsIVS application. Upload the form, select it in the Test Form Design page, and click GenerateCSS. You are not required to set the HTML transformation type before clicking the button. Next select save. You can edit this CSS file to meet your business requirements.
Summary of steps summary-of-steps
To render an HTML form that uses a CSS file, perform the following tasks:
- Include project files.
- Create a Forms Java API object.
- Reference the CSS file.
- Render an HTML form.
- Write the form data stream to the client web browser.
Include project files
Include necessary files in your development project. If you are creating a client application by using Java, include the necessary JAR files. If you are using web services, ensure that you include the proxy files.
Create a Forms Java API object
Before you can programmatically perform an operation supported by the Forms service, you must create a Forms client object.
Reference the CSS file
To render an HTML form that uses a custom CSS file, ensure that you reference an existing CSS file.
Render an HTML form
To render an HTML form, specify a form design that was created in Designer and saved as an XDP file. Select an HTML transformation type. For example, you can specify the HTML transformation type that renders a dynamic HTML for Internet Explorer 5.0 or later.
Rendering an HTML form also requires values, such as URI values needed to render other form types.
Write the form data stream to the client web browser
When the Forms service renders an HTML form, it returns a form data stream that you must write to the client web browser to make the HTML form visible to the user.
See also
Render an HTML form that uses a CSS file using the Java API
Including AEM Forms Java library files
Forms Service API Quick Starts
Render an HTML form that uses a CSS file using the Java API render-an-html-form-that-uses-a-css-file-using-the-java-api
Render an HTML form that uses a custom CSS file by using the Forms API (Java):
-
Include project files
Include client JAR files, such as adobe-forms-client.jar, in your Java project鈥檚 class path.
-
Create a Forms Java API object
- Create a
ServiceClientFactoryobject that contains connection properties. - Create a
FormsServiceClientobject by using its constructor and passing theServiceClientFactoryobject.
- Create a
-
Reference the CSS file
- Create an
HTMLRenderSpecobject by using its constructor. - To render the HTML form that uses a custom CSS file, invoke the
HTMLRenderSpec辞产箩别肠迟鈥檚setCustomCSSURImethod and pass a string value that specifies the location and name of the CSS file.
- Create an
-
Render an HTML form
Invoke the
FormsServiceClient辞产箩别肠迟鈥檚(Deprecated) (Deprecated) renderHTMLFormmethod and pass the following values:- A string value that specifies the form design name, including the file name extension. If you reference a form design that is part of a Forms application, ensure that you specify the complete path, such as
Applications/FormsApplication/1.0/FormsFolder/Loan.xdp. - A
TransformToenum 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, specifyTransformTo.MSDHTML. - A
com.adobe.idp.Documentobject that contains data to merge with the form. If you do not want to merge data, pass an emptycom.adobe.idp.Documentobject. - The
HTMLRenderSpecobject that stores HTML run-time options. - A string value that specifies the
HTTP_USER_AGENTheader value, such asMozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322). - A
URLSpecobject that stores URI values required to render an HTML form. - A
java.util.HashMapobject that stores file attachments. This is an optional parameter, and you can specifynullif you do not want to attach files to the form.
The
(Deprecated) renderHTMLFormmethod returns aFormsResultobject that contains a form data stream that must be written to the client web browser. - A string value that specifies the form design name, including the file name extension. If you reference a form design that is part of a Forms application, ensure that you specify the complete path, such as
-
Write the form data stream to the client web browser
- Create a
com.adobe.idp.Documentobject by invoking theFormsResultobject 'sgetOutputContentmethod. - Get the content type of the
com.adobe.idp.Documentobject by invoking itsgetContentTypemethod. - Set the
javax.servlet.http.HttpServletResponse辞产箩别肠迟鈥檚 content type by invoking itssetContentTypemethod and passing the content type of thecom.adobe.idp.Documentobject. - Create a
javax.servlet.ServletOutputStreamobject used to write the form data stream to the client web browser by invoking thejavax.servlet.h\ttp.HttpServletResponse辞产箩别肠迟鈥檚getOutputStreammethod. - Create a
java.io.InputStreamobject by invoking thecom.adobe.idp.Document辞产箩别肠迟鈥檚getInputStreammethod. - Create a byte array and populate it with the form data stream by invoking the
InputStream辞产箩别肠迟鈥檚readmethod and passing the byte array as an argument. - Invoke the
javax.servlet.ServletOutputStream辞产箩别肠迟鈥檚writemethod to send the form data stream to the client web browser. Pass the byte array to thewritemethod.
- Create a
See also
Rendering HTML Forms Using Custom CSS Files
Quick Start (SOAP mode): Rendering an HTML form that uses a CSS file using the Java API
Render an HTML form that uses a CSS file using the web service API render-an-html-form-that-uses-a-css-file-using-the-web-service-api
Render an HTML form that uses a custom CSS file by using the Forms API (web service):
-
Include project files
- Create Java proxy classes that consume the Forms service WSDL.
- Include the Java proxy classes in your class path.
-
Create a Forms Java API object
Create a
FormsServiceobject and set authentication values. -
Reference the CSS file
- Create an
HTMLRenderSpecobject by using its constructor. - To render the HTML form that uses a custom CSS file, invoke the
HTMLRenderSpec辞产箩别肠迟鈥檚setCustomCSSURImethod and pass a string value that specifies the location and name of the CSS file.
- Create an
-
Render an HTML form
Invoke the
FormsService辞产箩别肠迟鈥檚(Deprecated) renderHTMLFormmethod and pass the following values:- A string value that specifies the form design name, including the file name extension. If you reference a form design that is part of a Forms application, ensure that you specify the complete path, such as
Applications/FormsApplication/1.0/FormsFolder/Loan.xdp. - A
TransformToenum 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, specifyTransformTo.MSDHTML. - A
BLOBobject that contains data to merge with the form. If you do not want to merge data, passnull. (See Prepopulating Forms with Flowable Layouts.) - The
HTMLRenderSpecobject that stores HTML run-time options. - A string value that specifies the
HTTP_USER_AGENTheader value, such asMozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322). You can pass an empty string if you do not want to set this value. - A
URLSpecobject that stores URI values required to render an HTML form. - A
java.util.HashMapobject that stores file attachments. This is an optional parameter, and you can specifynullif you do not want to attach files to the form. - An empty
com.adobe.idp.services.holders.BLOBHolderobject that is populated by the(Deprecated) renderHTMLFormmethod. This parameter value stores the rendered form. - An empty
com.adobe.idp.services.holders.BLOBHolderobject that is populated by the(Deprecated) renderHTMLFormmethod. This parameter stores the output XML data. - An empty
javax.xml.rpc.holders.LongHolderobject that is populated by the(Deprecated) renderHTMLFormmethod. This argument stores the number of pages in the form. - An empty
javax.xml.rpc.holders.StringHolderobject that is populated by the(Deprecated) renderHTMLFormmethod. This argument stores the locale value. - An empty
javax.xml.rpc.holders.StringHolderobject that is populated by the(Deprecated) renderHTMLFormmethod. This argument stores the HTML rendering value that is used. - An empty
com.adobe.idp.services.holders.FormsResultHolderobject that will contain the results of this operation.
The
(Deprecated) renderHTMLFormmethod populates thecom.adobe.idp.services.holders.FormsResultHolderobject that is passed as the last argument value with a form data stream that must be written to the client web browser. - A string value that specifies the form design name, including the file name extension. If you reference a form design that is part of a Forms application, ensure that you specify the complete path, such as
-
Write the form data stream to the client web browser
- Create a
FormResultobject by getting the value of thecom.adobe.idp.services.holders.FormsResultHolder辞产箩别肠迟鈥檚valuedata member. - Create a
BLOBobject that contains form data by invoking theFormsResult辞产箩别肠迟鈥檚getOutputContentmethod. - Get the content type of the
BLOBobject by invoking itsgetContentTypemethod. - Set the
javax.servlet.http.HttpServletResponse辞产箩别肠迟鈥檚 content type by invoking itssetContentTypemethod and passing the content type of theBLOBobject. - Create a
javax.servlet.ServletOutputStreamobject used to write the form data stream to the client web browser by invoking thejavax.servlet.http.HttpServletResponse辞产箩别肠迟鈥檚getOutputStreammethod. - Create a byte array and populate it by invoking the
BLOB辞产箩别肠迟鈥檚getBinaryDatamethod. This task assigns the content of theFormsResultobject to the byte array. - Invoke the
javax.servlet.http.HttpServletResponse辞产箩别肠迟鈥檚writemethod to send the form data stream to the client web browser. Pass the byte array to thewritemethod.
- Create a
See also
Rendering HTML Forms Using Custom CSS Files
Invoking AEM Forms using Base64 encoding