Using the Taglib

Advantages

The FormEngine comes with a small tag library for initializing and rendering forms.

The FormEngine tag library offers the following advantages:

  • Use the FormEngine in web frameworks (i. e JSF, Spring), within other taglibs und JSPX templates which do not allow using scripting code.
  • Integrate and combine the tag library together with other tag libraries as JSTL and use the JSP Expression Language (EL) in your consistent Java EE web application.
  • Clean separation between logic and view

Declaration

For embedding a form in your page you need two taglib declarations. The first is the FormEngine tag library, the second is a taglib to embed all JavaScript and CSS resources needed by the form.

<%@ taglib prefix="fe" uri="http://www.imatics.de/forms" %>
<%@ taglib prefix="imx" uri="http://www.imatics.de/j2ee" %>

Initializing a form instance

The fe:load-form tag is used to initialize a form instance and to set the instance as an attribute to any scope (attributes var and scope).

The tag fe:load-form only supports providing an URL based form definition (URL to an XML file with attribute resourcePath).

Via embedded fe:runtime-param tags you can provide runtime parameters for the form instance. You can set a connector (attribute connector) or the data for a connector defined in the form definition (attribute connectorData) as well.

<fe:load-form resourcePath="/path/to/my/form.xml" var="form"
    connectorData="${param['id']}">
  <fe:runtime-param name="myParamName" value="${myParamValueVar}"/>
</fe:load-form>

Printing the HTML Resources

After initializing the form all JavaScript and CSS resources must be printed in the HTML head area. This is easily done with the tag imx:print-request-includes.

Rendering the Form

Now the initialized form can be rendered in the HTML body with the help of fe:render-form.

<html>
<head>
  <imx:print-request-includes/>
</head>

<body>
   <fe:render-form form="${form}"/>
</body>
</html>