10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Encapsulating Reusable Content UsingTag Files<br />

236<br />

TABLE 8–3 attribute Directive Attributes (Continued)<br />

Attribute Description<br />

deferredValueType (optional) <strong>The</strong> type resulting from the evaluation of the attribute’s value<br />

expression. <strong>The</strong> default is java.lang.String if no type is specified. If both<br />

deferredValueType and deferredValue are specified, deferredValue must be<br />

true. If deferredValue is true, the default of deferredValueType is<br />

java.lang.Object. Causes a translation error specified in a tag file with a JSP<br />

version less than 2.1.<br />

deferredMethod (optional) Indicates whether the tag attribute accepts deferred method<br />

expressions. If deferredMethod and deferredMethodSignature are specified<br />

then deferredMethod must be true. <strong>The</strong> default of deferredMethod is true if<br />

deferredMethodSignature is specified, otherwise the default of<br />

deferredMethod is false. <strong>The</strong> presence of a deferred-method element in an<br />

attribute definition precludes the inclusion of a deferred-value element.<br />

Causes a translation error if specified in a tag file with a JSP version less than 2.1.<br />

deferredMethodSignature (optional) <strong>The</strong> signature of the method to be invoked by the expression defined<br />

by the accompanying deferredMethod attribute. If deferredMethod is true and<br />

this attribute is not specified, the method signature defaults to void<br />

methodName(). Causes a translation error if specified in a tag file with a JSP<br />

version less than 2.1.<br />

fragment (optional) Whether this attribute is a fragment to be evaluated by the tag handler<br />

(true) or a normal attribute to be evaluated by the container before being passed<br />

to the tag handler.<br />

If this attribute is true:<br />

You do not specify the rtexprvalue attribute. <strong>The</strong> container fixes the<br />

rtexprvalue attribute at true.<br />

You do not specify the type attribute. <strong>The</strong> container fixes the type attribute at<br />

javax.servlet.jsp.tagext.JspFragment.<br />

Defaults to false.<br />

DeclaringTagVariables inTag Files<br />

Tag attributes are used to customize tag behavior much as parameters are used to customize the<br />

behavior of object methods. In fact, using tag attributes and EL variables, it is possible to<br />

emulate various types of parameters: IN, OUT, and nested.<br />

To emulate IN parameters, use tag attributes. A tag attribute is communicated between the<br />

calling page and the tag file when the tag is invoked. No further communication occurs between<br />

the calling page and the tag file.<br />

To emulate OUT or nested parameters, use EL variables. <strong>The</strong> variable is not initialized by the<br />

calling page but instead is set by the tag file. Each type of parameter is synchronized with the<br />

calling page at various points according to the scope of the variable. See “Variable<br />

Synchronization” on page 237 for details.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!