DataTable - Color

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

IdYearBrandColor
553eab141977FiatOrange
8dfa20f71967RenaultBlack
0613d7621960JaguarBlue
0bc84e9b1984FiatYellow
f4d00b031966BMWMaroon
9788d1462009VolkswagenBlue
6db1ad771987MercedesMaroon
716e82e11990HondaRed
a541813b1983VolkswagenYellow
6a21a1c61978FiatGreen
<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>