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

Compare with Current View Page History

« Previous Version 36 Next »

The framework provides a tag library decoupled from the view technology. In this section, we describe each tag in general terms, such as the attributes it supports, what the behaviors are, and so forth. Most tags are supported in all template languages (see JSP Tags, Velocity Tags, and FreeMarker Tags), but some are currently only specific to one language. Whenever a tag doesn't have complete support for every language, it is noted on the tag's reference page.

The types of tags can be broken in to two types: generic and UI. Besides function and responsibility, the biggest difference between the two is that the HTML tags support templates and themes. In addition to the general tag reference, we also provide examples for using these generic tags in each of the support languages.

(tick) Be sure to read the Tag Syntax document to learn how tag attribute syntax works.

Generic Tags

Generic tags are used for controlling the execution flow when the pages render. These tags also allow for data extraction from places other than your action or the value stack, such as Internationalization, JavaBeans, and including additional URLs or action executions.

  1. Control Tags provide control flow, such as if, else, and iterator.
  2. Data Tags allow for data manipulation or creation, such as bean, push, and i18n.

UI Tags

Unlike generic tags, UI tags do not provide much control structure or logic. Rather, they are focussed on using data, either from your action/value stack or from the Data Tags, and displaying data in rich and reusable HTML. All UI tags are driven by templates and themes. While generic tags simply output some content directly from the tag (if there is any content to output), the UI tags defer to a template, often grouped together as a theme, to do the actual rendering.

Template support allows UI tags to build a rich set of reusable HTML components that can be customized to fit exact requirements. For details, see Themes and Templates.

Themes and Templates

A must-read explanation of how themes and templates are uses when rendering UI tags.

Form Tags

provide all form-related UI output, such as form, textfield, and select.

Non Form Tags

provide all non-form-related UI output, such as a, div, and tabbedPanel.

Language Specific Tag Support

The framework strives to support multiple development environments. The framework does not impose a single template language. Almost any common language can be used, and there are hooks for new languages. By default, almost every single tag is supported in JSP, Velocity, and FreeMarker. In each of these sections, you'll find examples and techniques for applying the generic tag reference toward your specific language or template choice.

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 UI 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.NullPointerException

Javascript-Related Attributes

Error formatting macro: snippet: java.lang.NullPointerException

Tooltip Related Attributes

Error formatting macro: snippet: java.lang.NullPointerException

General Attributes

Error formatting macro: snippet: java.lang.NullPointerException

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
<@s.form action="updateAddress">
    <@saf.textfield label="Postal Code" name="postalCode" value="%{postalCode}"/>
    ...
</@s.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
<@s.form action="updateAddress">
    <@s.textfield label="Postal Code" name="postalCode"/>
    ...
</@s.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.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

Tag Reference

(lightbulb) For detailed descriptions of each tag, including usage examples, see the Tag Reference.

Generic Tags

Control Tags

  • if
  • elseIf
  • else
  • append
  • generator
  • iterator
  • merge
  • sort
  • subset

Data Tags

  • action
  • bean
  • debug
  • i18n
  • include
  • param
  • push
  • set
  • text
  • url
  • property

UI Tags

Form Tags

  • checkbox
  • checkboxlist
  • combobox
  • datepicker
  • doubleselect
  • head
  • file
  • form
  • hidden
  • label
  • optiontransferselect
  • optgroup
  • password
  • reset
  • select
  • submit
  • textarea
  • textfield
  • timepicker
  • token
  • updownselect

Non-Form UI Tags

  • a
  • actionerror
  • actionmessage
  • component
  • date
  • div
  • fielderror
  • panel
  • table
  • tabbedPanel
  • tree
  • treenode

(lightbulb) For detailed descriptions of each tag, including usage examples, see the Tag Reference.

  • No labels