DataTable - Color

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

IdYearBrandColor
7cdf7c0a1990AudiRed
0a7b683b1972BMWWhite
107dc2132009VolvoGreen
e83f8c371980MercedesOrange
beaa645d1975FordRed
cfcdba2f1975VolvoBrown
a2aa7c2b1973MercedesOrange
ed597bc01976VolkswagenBlack
0de601d42001FordYellow
cf1acd4c1973FiatYellow
<style type="text/css">
    .old {
        background-color: #fca752 !important;
        background-image: none !important;
        color: #000000 !important;
    }
</style>

<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>