The dataTable Tag
The dataTable Tag
<h:dataTable id=
"items"
captionClass=
"list-caption"
columnClasses=
"list-column-center, list-column-left,
list-column-right, list-column-center
"
footerClass=
"list-footer"
headerClass=
"list-header"
rowClasses=
"list-row-even, list-row-odd"
styleClass=
"list-background"
summary=
"#{bundle.ShoppingCart}"
value=
"#{cart.items}"
var=
"item">
<h:column headerClass=
"list-header-left">
<f:facet name=
"header">
<h:outputText value=
"#{bundle.ItemQuantity}" />
</f:facet>
<h:inputText id=
"quantity" size="4"
value=
"#{item.quantity}" >
...
</h:inputText>
...
</h:column>
<h:column>
<f:facet name=
"header">
<h:outputText value=
"#{bundle.ItemTitle}"/>
</f:facet>
<h:commandLink action=
"#{showcart.details}">
<h:outputText value=
"#{item.item.title}"/>
</h:commandLink>
</h:column>
...
<f:facet name=
"footer"
<h:panelGroup>
<h:outputText value=
"#{bundle.Subtotal}"/>
<h:outputText value=
"#{cart.total}" />
<f:convertNumber type=
"currency" />
</h:outputText>
</h:panelGroup>
</f:facet>
<f:facet name=
"caption"
<h:outputText value=
"#{bundle.Caption}"/>
</h:dataTable>
shows a data grid that this dataTable tag can display.
The example dataTable tag displays the books in the shopping cart as well as the quantity of
each book in the shopping cart, the prices, and a set of buttons, which the user can click to
remove books from the shopping cart.
Adding UI Components to a Page Using the HTML Component Tags
The Java EE 5 Tutorial · September 2007
338