DataTable - Color

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

IdYearBrandColor
6cdb20621975FiatBlack
742d5f331982FiatGreen
f1d3c00d1969HondaYellow
41fe70f32000VolkswagenOrange
16e8d7681998VolvoSilver
d82843ee1993BMWMaroon
8b81e2351993VolvoBlack
f5b8890b1982AudiBlue
95dc37382002AudiBrown
23694fec2006HondaYellow
<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>