January 2013
Intermediate to advanced
328 pages
7h 14m
English
The dataTable component provides conditional coloring on rows, which can be styled based on conditions.
A basic definition of a color-coded table that displays a list of cars follows:
<p:dataTable id="coloring" var="car" value="#{dataTableController.cars}"
rowStyleClass="#{car.year le 1975 ? 'colored' : null}">
<p:columnheaderText="Year">#{car.year}</p:column>
<p:columnheaderText="Name">#{car.name}</p:column>
</p:dataTable>The colored style definition could be as simple as the following:
<style type="text/css">
.colored {
background-color: #FF0000;
color: #FFFFFF;
}
</style>With the rowStyleClass attribute, style class can be defined for each row according the manufacturing year ...
Read now
Unlock full access