The Data Table Tag–h:dataTable, Simple Table, Headers and Footers, and Captions,

The Data Table Tag–h:dataTable
  • 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…)


Headers, Footers, and Captions:
  • 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:
Step - 01: Create a simple bean.
Step - 02: Create managed bean.
Step - 03: Create XHTML page.
Step - 04: Output.

Thanks a lot for query or your valuable suggestions related to the topic.

Previous Post Next Post

Contact Form