This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Form Tags
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 31 Next »

Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works.

Within the form tags, there are two classes of tags: the form tag itself, and all other tags, which make up the individual form elements. The behavior of the form tag is different than the elements enclosed within it.

Form Tag Themes

As explained in Themes and Templates, the HTML Tags (which includes Form Tags) are all driven by templates. Templates are grouped together to create themes. The framework bundles three themes in the distribution.

simple

Sometimes too simple

xhtml

Extends simple

(default)

ajax

Extends xhtml

The predefined themes can be used "as is" or customized.

xhtml layout

The xhtml theme renders out a two-column table. If a different layout is needed, do not write your own HTML. Create a new theme or utilize the simple theme.

Simple theme caveats

The downside of using the simple theme is that it doesn't support as many of the attributes that the other themes do. For example, the label attribute does nothing in the simple theme, and the automatic display of error messages is not supported.

Common Attributes

All the form tags extend the UIBean class. This base class provides a set of common attributes, that can be grouped in to three categories: templated-related, javascript-related, and general attributes. The individual attributes are documented on each tag's reference page.

In addition to the common attributes, a special attribute exists for all form element tags: form (${parameters.form}). The form property represents the attributes used to render the form tag, such as the form's id. In a template, the form's ID can be found by calling ${parameters.form.id}.

Template-Related Attributes

Error formatting macro: snippet: java.lang.IllegalArgumentException: Invalid url: must begin with a configured prefix.

Javascript-Related Attributes

Error formatting macro: snippet: java.lang.IllegalArgumentException: Invalid url: must begin with a configured prefix.

Tooltip Related Attributes

Error formatting macro: snippet: java.lang.IllegalArgumentException: Invalid url: must begin with a configured prefix.

General Attributes

Error formatting macro: snippet: java.lang.IllegalArgumentException: Invalid url: must begin with a configured prefix.

When some attributes don't apply

Some tag attributes may not be utilized by all, or any, of the templates. For example, the form tag supports the tabindex attribute, but none of the themes render the tabindex.

Value/Name Relationship

In many of the tags (except for the form tag) there is a unique relationship between the name and value attributes. The name attribute provides the name for the tag, which in turn is used as the control attribute when the form is submitted. The value submitted is bound to the name. In most cases, the name maps to a simple JavaBean property, such as "postalCode". On a submit, the value would be set to the property by calling the setPostalCode mutator.

Likewise, a form control could be populated by calling a JavaBean accessor, like getPostalCode. In the expression language, we can refer to the JavaBean property by name. An expression like "%{postalCode}" would in turn call getPostalCode.

Using Expressions to populate a form for editing
<@saf.form action="updateAddress">
    <@saf.textfield label="Postal Code" name="postalCode" value="%{postalCode}"/>
    ...
</@saf.form>

However, since the tags imply a relationship between the name and value, the value attribute is optional. If a value is not specified, by default, the JavaBean accessor is used instead.

Populating a form for editing, the easy way
<@saf.form action="updateAddress">
    <@saf.textfield label="Postal Code" name="postalCode"/>
    ...
</@saf.form>

While most attributes are exposed to the underlying templates as the same key as the attribute (${parameters.label}), the value attribute is not. Instead, it can be accessed via the nameValue key (${parameters.nameValue}). The nameValue key indicates that the value may have been generated from the name attribute rather than explicitly defined in the value attribute.

ID Name Assignment

All form tags automatically assign an ID to the control, but the ID can be overridden if needed.

Forms

The default ID is the action name. For example, "updateAddress".

Controls

The default ID is the form's name concatenated with the tag name. For example, "updateAddress_postalCode".

Required Attribute

The required attribute on many UI tags defaults to true only if you have client-side validation enabled, and a validator is associated with that particular field.

Tooltip

Error formatting macro: snippet: java.lang.IllegalArgumentException: Invalid url: must begin with a configured prefix.
Error formatting macro: snippet: java.lang.IllegalArgumentException: Invalid url: must begin with a configured prefix.

Form Tag Reference

Entering push and pop zone

All tags that push something onto the value stack (like i18n or bean tags) will pop those objects from the stack when its processing completes. If a bean is instantiated with the bean tag (<saf:bean name="br.univap.fcc.sgpw.util.FormattersHelper">) that bean will be available on the value stack only until the tag closes.

  1. checkbox - renders a checkbox input field
  2. checkboxlist - renders a list of checkboxes
  3. combobox - renders a widget that fills a text box from a select
  4. datepicker - renders a date selection widget using JavaScript and DOM
  5. doubleselect - renders a double select widget, where the second drop down depends on the first
  6. head - renders the HEAD section for specific themes, such as CSS and JavaScript imports
  7. file - renders a file input field
  8. form - renders an input form
  9. hidden - renders a hidden form field
  10. label - renders renders a label
  11. optiontransferselect- renders an option transfer select component which is basically two select box with buttons in between allowing entries of each select to get transfer between each other.
  12. optgroup - render an optgroup tag to be used within a select tag
  13. password - renders a password textfield
  14. radio - renders a radio button
  15. reset - renders a reset form button
  16. select - renders a select
  17. submit - renders a submit button
  18. textarea - renders a textarea
  19. textfield - renders a textfield
  20. token - renders a hidden field to stop double-submission of containing forms
  21. updownselect - renders a select component with buttons to move the elements in the select component up and down

Next: Non Form Tags

  • No labels