background image

Defines an EL Variable

<< Declaring Tag Variables for Tag Handlers | Programming Simple Tag Handlers >>
<< Declaring Tag Variables for Tag Handlers | Programming Simple Tag Handlers >>

Defines an EL Variable

TABLE 8­11
variable
Subelements
(Continued)
Element
Description
name-given |
name-from-attribute
Defines an EL variable to be used in the page invoking this tag. Either name-given or
name-from-attribute
must be specified. If name-given is specified, the value is the
name of the variable. If name-from-attribute is specified, the value is the name of an
attribute whose (translation-time) value at the start of the tag invocation will give the
name of the variable.
Translation errors arise in the following circumstances:
Specifying neither name-given nor name-from-attribute or both.
If two variable elements have the same name-given.
variable-class
(optional) The fully qualified name of the class of the object. java.lang.String is the
default.
declare
(optional) Whether or not the object is declared. True is the default. A translation
error results if both declare and fragment are specified.
scope
(optional) The scope of the variable defined. Can be either AT_BEGIN, AT_END, or
NESTED
(see
Table 8­12
). Defaults to NESTED.
Table 8­12
summarizes a variable's availability according to its declared scope.
TABLE 8­12
Variable Availability
Value
Availability
NESTED
Between the start tag and the end tag.
AT_BEGIN
From the start tag until the scope of any enclosing tag. If there's no enclosing tag, then to the
end of the page.
AT_END
After the end tag until the scope of any enclosing tag. If there's no enclosing tag, then to the
end of the page.
You can define the following variable element for the tlt:iterator tag:
<tag>
<variable>
<name-given>var</name-given>
<variable-class>java.lang.String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
</variable>
</tag>
Tag Library Descriptors
Chapter 8 · Custom Tags in JSP Pages
255