background image

The first Attribute

<< The UIData Component | The UIPanel Component >>
<< The UIData Component | The UIPanel Component >>

The first Attribute

In the dataTable tag from the bookshowcart.jsp page, the value attribute points to a list of
books. The var attribute points to a single book in that list. As the UIData component iterates
through the list, each reference to item points to the current book in the list.
The UIData component also has the ability to display only a subset of the underlying data. This
is not shown in the preceding example. To display a subset of the data, you use the optional
first
and rows attributes.
The first attribute specifies the first row to be displayed. The rows attribute specifies the
number of rows, starting with the first row, to be displayed. For example, if you wanted to
display records 2 through 10 of the underlying data, you would set first to 2 and rows to 9.
When you display a subset of the data in your pages, you might want to consider including a
link or button that causes subsequent rows to display when clicked. By default, both first and
rows
are set to zero, and this causes all the rows of the underlying data to display.
The dataTable tag also has a set of optional attributes for adding styles to the table:
captionClass
: Defines styles for the table caption
columnClasses
: Defines styles for all the columns
footerClass
: Defines styles for the footer
headerClass
: Defines styles for the header
rowClasses
: Defines styles for the rows
styleClass
: Defines styles for the entire table
Each of these attributes can specify more than one style. If columnClasses or rowClasses
specifies more than one style, the styles are applied to the columns or rows in the order that the
styles are listed in the attribute. For example, if columnClasses specifies styles
list-column-center
and list-column-right and if there are two columns in the table, the
first column will have style list-column-center, and the second column will have style
list-column-right
.
If the style attribute specifies more styles than there are columns or rows, the remaining styles
will be assigned to columns or rows starting from the first column or row. Similarly, if the style
attribute specifies fewer styles than there are columns or rows, the remaining columns or rows
will be assigned styles starting from the first style.
Adding Graphics and Images with the graphicImage
Tag
In a JavaServer Faces application, the UIGraphic component represents an image. The
graphicImage
tag is used to render a UIGraphic component on a page. The Duke's Bookstore
application uses a graphicImage tag to display the map image on the chooselocale.jsp page:
<h:graphicImage id=
"mapImage" url="/template/world.jpg"
alt=
"#{bundle.chooseLocale}" usemap="#worldMap" />
Adding UI Components to a Page Using the HTML Component Tags
The Java EE 5 Tutorial · September 2007
340