Form Processor Macros

The iKnowBase Presentation Services' Form Processor provides directives used to render form elements in a plugin development environment.

Requirements:

Overview

The figure below gives a quick overview of the models available:

Note: “form” is the default and recommended name, but it may be changed when you register the form macro on the Form Processor.
Note: The model name “form” is also used by the Activiti Form Viewer.

FormModel

This object contains directives used to render form elements for backing bean properties annotated with iKnowBase AttributeMapping.

Property Description Type
input Directive used to create and render a UI component for the form FormInputDirective
label Directive used to render a label for a component of the form FormLabelDirective
bindingFieldErrors Directive and model used to render any binding errors for the currently submitted form. FormBindingFieldErrors
message Directive used to render a language specific message from the message source (set of property files) FormMessageDirective
resources Directive used to render html for including the external resources required by the Plugin form macro directives. FormResourcesDirective

FormInputDirective

This directive is used to create a form component and render an input field for an iKnowBase AttributeMapping-annotated bean property. The directive will automatically adapt its defaults according to the annotations present on the property, including the referenced iKnowBase attribute definition.

Parameter Description Type
name Name of the iKnowBase annotated bean property you want to render input field for; this will also be the “name” attribute in the html form. String
type Type of input field, according to table below. Default value will depend on type of the bound object String
<default> Other parameters are rendered as they are, allowing any html attribute to be used and rendered. String

The input fields can take many different forms, depending on its type. The type is initially decided from the underlying data field, such that a numeric field will render as a number field. You can also specify a type manually to override this; this is particularly useful when a single field type has many possible renderings (such as a list of values, which can render as select or radio, and sometimes even as a popup).

Type Description
favoritepopup For dimensions only: Renders a popup AND an additional select box with the last used dimensions for the current user
personalacl An ACL popup with iKnowBase personal acl functionality
popup Popup button, with values populated from underlying data field.
textarea Normal text area (available in input directibe, but will be a textarea html tag)
<default> Any HTML compatible input type (like date, datetime-local, number, text, select, checkbox, radio, ...)

Examples:

<!-- Default input field -->
[@form.input name="title" /]
<!-- Renders a dimension navigator, a drop-down to select dimensions and a user popup to select user, based on attribute definitions and explit forced type -->
[@form.input name="organization" type="popup" /] <!-- NOTE: popup is default and therefore optional on this attribute -->
[@form.input name="brand" type="select" /]
[@form.input name="manager" type="popup" /]

FormLabelDirective

This directive is used to render a label for an iKnowBase AttributeMapping-annotated bean property, using the langiage specific label defined for the attribute.

Parameter Description Type
name Name of the iKnowBase annotated bean property you want to render label for String
<default> Other parameters are rendered as they are, allowing any html attribute to be used and rendered. String

Example:

[@form.label name="description" /]

FormBindingFieldErrors

form.bindingFieldErrors can be used both as a directive and as a model:

Parameter Description Type
name Name of the iKnowBase annotated bean property you want to render label for. If ommitted, display errors for all fields String
separator If there are more than one error, use this HTML separator between messages String

Examples:

<!-- A typical scenario rendering all error messages for all form fields -->
[@form.bindingFieldErrors separator="<br>" class="error" /]
<!-- A typical scenario rendering a label, an input field and an error message -->
<tr>
<td>[@form.label name="title" /]</td>
<td>[@form.input name="title" /]</td>
<td>[@form.bindingFieldErrors name="title" separator="<br>" class="error" /]</td>
</tr>
<!-- All errors -->
[#list form.bindingFieldErrors! as fieldError]
    ${fieldError.field} - ${fieldError.rejectedValue!} - ${fieldError.defaultMessage!} - ${fieldError.localizedMessage!} <br />
[/#list]
<!-- Errors for documentType property only --> 
[#list form.bindingFieldErrors.documentType! as fieldError]
    ${fieldError.field} - ${fieldError.rejectedValue!} - ${fieldError.defaultMessage!} - ${fieldError.localizedMessage!} <br />
[/#list]

FormMessageDirective

This directive is used to render a language specific message for a given code contained within the Form Processor’s MessageSource (you’ll specify it during construction of the Form Processor), which may contain a set of property files specific for your plugin.

Parameter Description Type
code Key of property in message source (property files) String
default Default message if the key was not found in message source String
[@form.message code="myLocalizedFormTitle" default="A default form title" /]

FormResourcesDirective

This directive is used to render html for including the external resources required by the Plugin form macro directives.

[@form.resources /]