background image

Deferred Value and Method

<< Dynamic Attributes | Tags with Bodies >>
<< Dynamic Attributes | Tags with Bodies >>

Deferred Value and Method

Deferred Value
A deferred value attribute is one that accepts deferred value expressions, which are described in
"Value Expressions" on page 150
.
Deferred Method
A deferred method attribute is one that accepts deferred method expressions, which are
described in
"Method Expressions" on page 154
.
Dynamic Attribute or Deferred Expression
This kind of attribute can accept a String literal, a scriptlet expression, or an EL expression,
including deferred expressions.
jsp:attribute
Element
The jsp:attribute element allows you to define the value of a tag attribute in the body of an
XML element instead of in the value of an XML attribute.
For example, the Duke's Bookstore template page screendefinitions.jsp uses
jsp:attribute
to use the output of fmt:message to set the value of the value attribute of
tt:parameter
:
...
<tt:screen id=
"/bookcatalog">
<tt:parameter name=
"title" direct="true">
<jsp:attribute name=
"value" >
<fmt:message key=
"TitleBookCatalog"/>
</jsp:attribute>
</tt:parameter>
<tt:parameter name=
"banner" value="/template/banner.jsp"
direct=
"false"/>
<tt:parameter name=
"body" value="/bookcatalog.jsp"
direct=
"false"/>
</tt:screen>
...
jsp:attribute
accepts a name attribute and a trim attribute. The name attribute identifies
which tag attribute is being specified. The optional trim attribute determines whether or not
white space appearing at the beginning and end of the element body should be discarded. By
default, the leading and trailing white space is discarded. The white space is trimmed when the
JSP page is translated. If a body contains a custom tag that produces leading or trailing white
space, that white space is preserved regardless of the value of the trim attribute.
An empty body is equivalent to specifying "" as the value of the attribute.
Types of Tags
Chapter 8 · Custom Tags in JSP Pages
231