Form-Based Input
Tammi provides powerful tools to define field containers for requesting
and managing HTML form-based input. These containers are implemented as dynamic
variables and their fields act as attributes of the variables.
The implementation is based on the following classes:
- Instances of
VariableAttributeInfo define one attribute each.
Lists of attribute instances are registered to the variable registry with a named type.
Variable defines a dynamic container of attributes
implemented by VariableX as a dynamic MBean.
The variable registry creates instances of VariableX based on
the named and registered attribute lists. The variable treats the named type of its
attribute list as its virtual class name.
VariableRegistry defines the variable registry. It maintains
metadata of attributes for each registered attribute list. The default variable registry
is created during the startup process to the default domain, and it may be shared by
all plug-in applications.
FormFilter can be applied through the $form
tool to automatically render an entire form containing controls for requesting input
data as values of attributes of a VariableX instance.
See Javadoc of FormFilter and FormTool for more information.
By using variables, you only need to program attribute and variable definitions
and still get quite sophisticated functionality. Based on your attribute definitions,
Tammi renders the appropriate HTML control like a textbox, a check box, a selection list,
or whatever matches best the name and type of the attribute. User input is validated against
the metadata definition if you have specified ranges or an enumeration of valid values.
The following attribute types have ready-made implementations: primitive Java types,
the corresponding Java classes, strings, JMX object names and MBean references.
Arrays of all types are also supported. Custom converters to handle localized input
and output of dates and numbers are part of the framework, and additional converters
can be included with little effort.
Validation of input data is done on the server side in a user friendly way.
After the input data has been submitted and validated, all erroneous fields on
the form are highlighted and a descripive message displayed. This approach does
not require JavaScript, works with all browsers, and has been tested to be efficient
enough in normal network conditions.
You have many options to extend the framework. You may define the HTML counterpart
of a new variable class by writing the corresponding control template for input and output
or override Tammi's default behavior, either globally or per variable and attribute,
by adding control template variations for existing types.
You can implement a custom converter for parsing textual HTML input to
the corresponding Java type and, vice versa, for converting a Java type to
its string representation. Conversion methods of custom converters get
a metadata pattern, value ranges and an input locale as parameters making
them flexible and capable of participating in the input
validation process, too. You may extend the validation process by implementing
a custom validator, e.g. to cross-check all fields within a form.
You can also implement your own classes, apply them as attribute types,
and define their HTML counterparts as control templates.
|