May 2015
Beginner to intermediate
412 pages
8h 44m
English
The dataTable component provides conditional coloring on rows, which can be styled based on conditions. The row styling utilizes the rowStyleClass attribute that has a condition as the EL expression.
In this recipe, we will demonstrate the conditional coloring on rows for countries with GDP (gross domestic product) less than $3,500,000.
A basic definition of a color-coded table that displays a list of countries with their GDPs is given here:
<p:dataTable value="#{dataTableColoringBean.countryGdpList}" var="countryGdp" rowStyleClass="#{countryGdp.gdp le 3500000 ? 'colored' : ''}"> <p:column headerText="Name" sortBy="#{countryGdp.name}"> #{countryGdp.name} </p:column> <p:column headerText="GDP (Millions ...Read now
Unlock full access