FormBuilder
Introduction
For most Java EE web applications, entity beans directly determine the contents
of many view forms. For example, a person is represented in the domain model
by a Person entity bean with properties like name, password, etc.
The properties are then typically propagated directly to a corresponding
view form. Manual view form development and maintenance is error-prone
and tedious. When developing the view form, we must focus not only on
accurately reproducing field names and types but also on additional
properties, such as default values, constraints, etc. Any changes
at the entity bean level must be propagated to the corresponding
view forms. In addition, view form errors are difficult to detect
because of weak type safety and limited mechanisms for constraint
verification. The FormBuilder tool provides automated construction
and maintenance of view forms based on entity bean fields and
annotations.
In this guide I expect that you have a basic knowledge of JBoss Hibernate validation.
Features
- template based view form generation (expected form usage as facelets tag)
- new field property annotations (password, html, link, etc)
- ability to define your own tag library for form generation (Tag?)
- user option of JSF components to use
- user can specify propagated parameters in your tag
- ability to define own library (Trinidad, Tomahwak, ICEfaces...)
- prepared tag 2 libraries (JSF, JBoss Seam + RichFaces)
- client side validation (Firefox 2, Internet Explorer 7, Opera, Safari 3, GNOME Epiphany)
- internationalization for client side validation
- ability to provide view/edit switching in one component
- field-level security property for selectively rendering field (configuration by exception)
- new behavior tags based on field property (password, html, link, color)
- configurable field to tag mapping
- configurable tags and usage templates for your application
- field to tag mapping can consider specific condition
- condition by field name
- condition by field annotation value
- configurable field filtering - exceptions to omit from mapping
- simple xml configuration
Description
Quick steps overview
- 1. Define the entity bean and annotate the fields (Input 1: person.java).
- 2. Specify the view component tags for
the various field (sub)types
-
<my:inputText .../> --> inputText.xhtml (Wrapper)
-
<rich:calender .../>
-
<tr:inputNumberSpinner .../>
- 3. Configure FormBuilder in form-config.xml (Input 2: form-config.xml).
- 1. Mapping between entity bean fields types and view component templates (marked usage of view component tag)
String -> inputTextTag.xhtml
int -> tr:inputNumberTag.xhtml
Integer -> tr:inputNumberTag.xhtml
String(@email) -> emailTag.xhtml
- 2. Location of input and output path for FormBuilder (where from to read templates, where to put generated form)
- 3. Define entity bean field filters (Ignored fields)
- 4. Run FormBuilder
- 1. from command line (parameter entity bean (String))
- 2. from eclipse (other IDE) (parameter entity bean (String, Class))
- 5. Form is generated with entity bean name (Output: person.xhtml)
Configuration
To start the description of the tool I will show its life cycle at Figure 1.
The input is an entity bean that you want to use for form generation and then your configuration.

Figure 1.
Tool also offers two prepared tag libraries. First uses only simple JSF and second Seam UI and RichFaces.
If you are going to develop your application under JBoss Seam you can extend existing configuration
and take a look at example that is provided with the tool. If you want to use the tool
somewhere else you will need to define the mapping of field types to
inputTags.
You can refine your mapping according guard conditions. Guard conditions are evaluated and first
satisfied condition will determine
inputTag to use. Simple example:
<use-types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:edu.baylor.icpc.formbuilder.config.UseType">
<default-length>255</default-length>
<default-size>30</default-size>
<name>String</name>
<file-path>inputTextTag.xhtml</file-path>
<guards xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:java.lang.String">email == true</guards>
<guards xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:java.lang.String">maxLength > 255</guards>
<guard-file-paths xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:java.lang.String">emailTag.xhtml</guard-file-paths>
<guard-file-paths xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:java.lang.String">inputTextAreaTag.xhtml</guard-file-paths>
</use-types>
The code says that
String field is mapped in tag
inputTextTag.xhtml. And that default field length is 255 and default input size is 30.