DataTable - Color

Certain rows can be styled based on a condition using rowStyleClass. Table below highlights cars that are manufactured before 1990.

IdYearBrandColor
c44cd35f1962JaguarOrange
00dd160d1966AudiYellow
0fa922551985FiatBlack
e8d24bc91976AudiSilver
24f24fbf1999VolkswagenYellow
bb84b3b71973VolvoMaroon
f0c44dd71985FiatMaroon
08b8da971976FiatYellow
15fc2af71990FiatBlack
1d5153121981JaguarMaroon
<p:dataTable var="car" value="#{dtBasicView.cars}" rowStyleClass="#{car.year le 1990 ? 'old' : null}">
    <p:column headerText="Id">
        <h:outputText value="#{car.id}" />
    </p:column>

    <p:column headerText="Year">
        <h:outputText value="#{car.year}" />
    </p:column>

    <p:column headerText="Brand">
        <h:outputText value="#{car.brand}" />
    </p:column>

    <p:column headerText="Color">
        <h:outputText value="#{car.color}" />
    </p:column>
</p:dataTable>