background image

Declaring Tag Attributes for Tag Handlers

<< Declaring Tag Handlers | attribute Subelements >>
<< Declaring Tag Handlers | attribute Subelements >>

Declaring Tag Attributes for Tag Handlers

TABLE 8­9
tag
Subelements
(Continued)
Element
Description
dynamic-attributes
Whether the tag supports additional attributes with dynamic names. Defaults to
false
. If true, the tag handler class must implement the
javax.servlet.jsp.tagext.DynamicAttributes
interface.
example
(optional) Informal description of an example use of the tag.
tag-extension
(optional) Extensions that provide extra information about the tag for tools.
body-content
Element
You specify the type of body that is valid for a tag by using the body-content element. This
element is used by the web container to validate that a tag invocation has the correct body
syntax and is used by page-composition tools to assist the page author in providing a valid tag
body. There are three possible values:
tagdependent
: The body of the tag is interpreted by the tag implementation itself, and is
most likely in a different language, for example, embedded SQL statements.
empty
: The body must be empty.
scriptless
: The body accepts only static text, EL expressions, and custom tags. No
scripting elements are allowed.
Declaring Tag Attributes for Tag Handlers
For each tag attribute, you must specify whether the attribute is required, whether the value can
be determined by an expression, the type of the attribute in an attribute element (optional),
and whether the attribute is a fragment. If the rtexprvalue element is true or yes, then the
type
element defines the return type expected from any expression specified as the value of the
attribute. For static values, the type is always java.lang.String. An attribute is specified in a
TLD in an attribute element.
Table 8­10
lists the subelements of the attribute element.
TABLE 8­10
attribute
Subelements
Element
Description
description
(optional) A description of the attribute.
name
The unique name of the attribute being declared. A translation error results if more
than one attribute element appears in the same tag with the same name.
required
(optional) Whether the attribute is required. The default is false.
Tag Library Descriptors
The Java EE 5 Tutorial · September 2007
252