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. This is important as the behavior of the form tag itself is different than that of the elements enclosed within it. Before we go provide a reference for all the form tags, including the form tag itself, we must outline some general characteristics first.

Form Tag Themes

As previously noted, the HTML Tags (which includes Form Tags) are all driven by templates. Templates are grouped together to form themes. By default, WebWork provides three themes:

Remember: the xhtml theme renders out a two-column table. If you need a different layout, we highly recommend that you do not write your own HTML, but rather create your own theme or utilize the simple theme.

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. Similarly, the functionality offered by the simple theme is much less than that of the xhtml and ajax themes: the automatic display of error messages is not supported.

Common Attributes

All the form tags extend the UIBean class. This base class generally common attributes, grouped in to three classes: templated-related, javascript-related, and general attributes. We won't document what these attributes do here as that is taken care of in each individual tag's reference. However, it is a good idea to familiarize yourself with the structure of the UI tags and what attributes are available for all tags.

In addition to these attributes, a special attribute exists for all form element tags: form (ie: ${parameters.form}). This represents the parameters used to render the form tag and allows you to provide interaction between your form elements and the form itself. For example, in a template you could access the form's ID by calling ${parameters.form.id}.

Template-Related Attributes

TODO: need to include code from UIBean.java

Javascript-Related Attributes

TODO: need to include code from UIBean.java

General Attributes

TODO: need to include code from UIBean.java

When Some Attributes Don't Apply

Note that some tags don't don't have any templates that utilize certain attributes, either because it doesn't make sense or it isn't required. For example, the form tag, while it supports the tabindex attribute, none of the themes render it out. Also, as mentioned, certain themes won't utilize some attributes.

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 is what the form element gets named and eventually submitted as. This effectively is the expression to which you wish to bind the incoming value to. In most cases, it is a simple JavaBean property, such as "firstName". This would eventually call setFirstName().

Similarly, you often wish to also display in your form elements existing data from the same JavaBean property. This time, the attribute value is used. A value of "%{firstName}" would call getFirstName() and display it in your form, allowing users to edit the value and re-submit it.

You could use the following code, and it would work just fine:

<@ww.form action="updatePerson">
    <@ww.textfield label="First name" name="firstName" value="%{firstName}"/>

However, because the relationship between name and value is so often predictable, we automatically do this for you, allowing you to do:

<@ww.form action="updatePerson">
    <@ww.textfield label="First name" name="firstName"/>

While most attributes are exposed to the underlying templates as the same key as the attribute (ie: ${parameters.label}), the value attribute is not. Instead, it can be accessed via the "nameValue" key (ie: ${parameters.nameValue}) to indicate that it 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 for you. You are free to override this ID if you wish. The ID assignment works as follows:

  1. For forms, the ID is the assumed to the action name. In the previous example, the ID would be "updatePerson".
  2. For form elements, the ID is assumed to be form's ID_element name

Form Tag Reference

  1. form
  2. textfield
  3. textarea
  4. select
  5. radio
  6. submit
  7. checkbox
  8. checkboxlist
  9. token
  10. label
  11. password
  12. hidden
  13. combobox
  14. doubleselect
  15. file
  16. datepicker