Skip to end of metadata
Go to start of metadata

Decorators

Most Loom tags have an associated Decorator instance that is invoked before and after the tag itself. Decorators are searched by looking for the tag class name, then each superclass.

The default decorator can be overriden using the "decorator" attribute. The default decorator for form fields will render the field label, input field, and associated error message, if any.

Input field decorator tuning

The default input field decorator uses some tag attributes to modify the generated HTML:

  • renderLabel: if false, the form input field will not generate any label. Defaults true.
  • translateLabel: true to translate the label before rendering. Defaults true.
  • renderAsText: if true, plain text will be rendered instead of a form field (label options still apply). Defaults to false.
  • renderErrorDisplayComponent: render a separate error display component. If false, the component errors will be shown in a common error display rendered by an <l:errors> tag. Defaults to true.
  • labelPosition: Sets the position of the input component label. Default is left for all fields but checkboxes and radio buttons

Some of these values can be changed in the containing form, in which case the value will be the default for all nested input fields.

Registered decorators

New decorators can be registered at TagDecoratorRepository. The default list is as follows; to use them, just specify the decorator using the "decorator" attribute.

  • print: print the field value. Intended for use with <inputHidden> fields.
  • inline and nested: the type of menu decorator to use. Inline will display the menu items as a single list of links, while nested will use a hierarchy of nested <ul> tags.
  • link-only: when used with a <l:url> tag, only the link destination will be printed.

Render as text

When renderAsText=true, the field will be rendered as plain text. This means that instead of the usual label and text field, the browser will see something like this:

When rendering as text, each component behaves different:

  • InputText renders the field value. If the size property has been set and the field value is bigger than that, it gets truncated and replaced with an ellipsis ("Some very big val...")
  • InputSelect and InputRadio displays the selected option label
  • InputCheckbox displays the translated string of the field name + ".true" or ".false", depending on the value

Internally, renderAsText is implemented using a ReadOnlyDecorator, so it can be overriden by specifying your own decorator instead.


‹ Checkbox
up
Form tags ›

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.