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.

<strong>The</strong> url attribute specifies the path to the image. It also corresponds to the local value of the<br />

UIGraphic component so that the URL can be retrieved, possibly from a backing bean. <strong>The</strong><br />

URL of the example tag begins with a /, which adds the relative context path of the web<br />

application to the beginning of the path to the image.<br />

<strong>The</strong> title attribute specifies the alternative text displayed when the user mouses over the<br />

image. In this example, the title attribute refers to a localized message. See “Performing<br />

Localization” on page 388 for details on how to localize your <strong>Java</strong>Server Faces application.<br />

<strong>The</strong> usemap attribute refers to the image map defined by the custom component,<br />

MapComponent, which is on the same page. See Chapter 13, “Creating Custom UI Components,”<br />

for more information on the image map.<br />

Laying Out Components with the UIPanel Component<br />

In a <strong>Java</strong>Server Faces application, you use the UIPanel component as a layout container for a set<br />

of component components. When you use the renderers from the HTML render kit, UIPanel is<br />

rendered as an HTML table. This component differs from UIData in that UIData can<br />

dynamically add or delete rows to accommodate the underlying data source, whereas UIPanel<br />

must have the number of rows predetermined. Table 11–4 lists all the renderers and tags<br />

corresponding to the UIPanel component.<br />

TABLE 11–4 UIPanel Renderers and Tags<br />

Renderer Tag Renderer Attributes Function<br />

Grid panelGrid columnClasses, columns, footerClass,<br />

headerClass, panelClass, rowClasses<br />

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

Displays a table<br />

Group panelGroup layout Groups a set of components<br />

under one parent<br />

<strong>The</strong> panelGrid tag is used to represent an entire table. <strong>The</strong> panelGroup tag is used to represent<br />

rows in a table. Other UI component tags are used to represent individual cells in the rows.<br />

<strong>The</strong> panelGrid tag has a set of attributes that specify CSS stylesheet classes: columnClasses,<br />

footerClass, headerClass, panelClass, and rowClasses. <strong>The</strong>se stylesheet attributes are<br />

optional. <strong>The</strong> panelGrid tag also has a columns attribute. <strong>The</strong> columns attribute is required if<br />

you want your table to have more than one column because the columns attribute tells the<br />

renderer how to group the data in the table.<br />

If the headerClass attribute value is specified, the panelGrid must have a header as its first<br />

child. Similarly, if a footerClass attribute value is specified, the panelGrid must have a footer<br />

as its last child.<br />

<strong>The</strong> Duke’s Bookstore application includes three panelGrid tags on the bookcashier.jsp page.<br />

Here is a portion of one of them:<br />

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

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

Saved successfully!

Ooh no, something went wrong!