The Data Table Tag–h:dataTable
Style:
- The h:dataTable tag iterates over data to create an HTML table.
- The value attribute represents the data over which h:dataTable iterates; that data must be one of the following:
- A Java object
- An array
- An instance of java.util.List
- An instance of java.sql.ResultSet
- An instance of javax.servlet.jsp.jstl.sql.Result
- An instance of javax.faces.model.DataModel
- The name of the item is specified with h:dataTable’s var attribute.
- The body of h:dataTable tags can contain only h:column tags;
- h:dataTable ignores all other component tags.
- Each column can contain an unlimited number of components. (as well as optional headers, footers…)
- To supply a table caption, add a caption facet, like this:
- Example:
- You can use captionStyle and captionClass to specify a style or CSS class, respectively, for the caption:
- Example:
Style:
- h:dataTable has attributes that specify CSS classes for the following:
- The table as a whole (styleClass)
- Column headers and footers (headerClass and footerClass)
- Individual columns (columnClasses)
- Individual rows (rowClasses)
- Example of Styles by Column:
- Example of Styles by Row:
Example of Simple Table:
Tags:
Java