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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Adding UI Components to a Page Using the HTML Component<br />

Tags<br />

<strong>The</strong> tags defined by the <strong>Java</strong>Server Faces standard HTML render kit tag library represent HTML<br />

form components and other basic HTML elements. <strong>The</strong>se components display data or accept<br />

data from the user. This data is collected as part of a form and is submitted to the server, usually<br />

when the user clicks a button. This section explains how to use each of the component tags<br />

shown in Table 10–2.<br />

<strong>The</strong> next section explains the more important tag attributes that are common to most<br />

component tags. Please refer to the TLD documentation at http://download.oracle.com/<br />

docs/cd/E17477_01/javaee/5/javaserverfaces/1.2/docs/tlddocs/ for a complete list of<br />

tags and their attributes.<br />

For each of the components discussed in the following sections, “Writing Bean Properties” on<br />

page 377 explains how to write a bean property bound to a particular UI component or its value.<br />

UI ComponentTag Attributes<br />

In general, most of the component tags support these attributes:<br />

■ id: Uniquely identifies the component.<br />

■ immediate: If set to true, indicates that any events, validation, and conversion associated<br />

with the component should happen in the apply request values phase rather than a later<br />

phase.<br />

■ rendered: Specifies a condition in which the component should be rendered. If the<br />

condition is not satisfied, the component is not rendered.<br />

■ style: Specifies a Cascading Style Sheet (CSS) style for the tag.<br />

■ styleClass: Specifies a CSS stylesheet class that contains definitions of the styles.<br />

■ value: Identifies an external data source and binds the component’s value to it.<br />

■ binding: Identifies a bean property and binds the component instance to it.<br />

All of the UI component tag attributes (except id) can accept expressions, as defined by the<br />

unified EL described in “Unified Expression Language” on page 146.<br />

<strong>The</strong> id Attribute<br />

Adding UI Components to a Page Using the HTML ComponentTags<br />

<strong>The</strong> id attribute is not required for a component tag except in the case when another<br />

component or a server-side class must refer to the component. If you don’t include an id<br />

attribute, the <strong>Java</strong>Server Faces implementation automatically generates a component ID. Unlike<br />

most other <strong>Java</strong>Server Faces tag attributes, the id attribute only takes expressions using the<br />

immediate evaluation syntax, which uses the ${} delimiters.<br />

Chapter 11 • Using <strong>Java</strong>Server FacesTechnology in JSP Pages 325

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

Saved successfully!

Ooh no, something went wrong!