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.

ody-content Attribute<br />

You specify the type of a tag’s body content using the body-content attribute:<br />

bodycontent="empty | scriptless | tagdependent"<br />

You must declare the body content of tags that do not accept a body as empty. For tags that have<br />

a body there are two options. Body content containing custom and standard tags and HTML<br />

text is specified as scriptless. All other types of body content (for example, SQL statements<br />

passed to the query tag) is specified as tagdependent. If no attribute is specified, the default is<br />

scriptless.<br />

DeclaringTag Attributes inTag Files<br />

To declare the attributes of a custom tag defined in a tag file, you use the attribute directive. A<br />

TLD has an analogous attribute element (see “Declaring Tag Attributes for Tag Handlers” on<br />

page 250). Table 8–3 lists the attribute directive attributes.<br />

TABLE 8–3 attribute Directive Attributes<br />

Attribute Description<br />

Encapsulating Reusable Content UsingTag Files<br />

description (optional) Description of the attribute. Defaults to no description.<br />

name <strong>The</strong> unique name of the attribute being declared. A translation error results if<br />

more than one attribute directive appears in the same translation unit with the<br />

same name.<br />

A translation error results if the value of a name attribute of an attribute<br />

directive is equal to the value of the dynamic-attributes attribute of a tag<br />

directive or the value of a name-given attribute of a variable directive.<br />

required (optional) Whether this attribute is required (true) or optional (false).<br />

Defaults to false.<br />

rtexprvalue (optional) Whether the attribute’s value can be dynamically calculated at<br />

runtime by an expression. Defaults to true. When this element is set to true and<br />

the attribute definition also includes either a deferred-value or<br />

deferred-method element then the attribute accepts both dynamic and deferred<br />

expressions.<br />

type (optional) <strong>The</strong> runtime type of the attribute’s value. Defaults to<br />

java.lang.String.<br />

deferredValue (optional) Indicates whether the attribute accepts deferred value expressions.<br />

Only one of deferredValue or deferredMethod can be true. If<br />

deferredValueType is specified, the default for deferredValue is true. Causes<br />

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

Chapter 8 • CustomTags in JSP Pages 235

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

Saved successfully!

Ooh no, something went wrong!