Styling tables

Almost all JSF UI components support the style and styleClass attributes for creating custom designs using CSS. But the <h:dataTable> tag supports attributes, such as captionClass, captionStyle, columnClasses, rowClasses, headerClass, and footerClass. Therefore, we should have no problem in adding a CSS style to every single part of a table (header, footer, caption, and so on). Obviously, there are plenty of examples that can be built, but let's see three of the most impressive and used ones.

Alternate row colors with the rowclasses attribute

The rowClasses attribute is used to indicate a string of CSS classes separated by a comma. The string is parsed by JSF, and the styles are applied sequentially and repeatedly to rows. For example, ...

Get Mastering JavaServer Faces 2.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.