DataTable - Color

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

IdYearBrandColor
e5ecdb282005VolkswagenMaroon
09b686a51999VolkswagenBlue
a92c89c81993VolkswagenRed
6ef898021974JaguarMaroon
35d977082009FiatSilver
b49e0f521960JaguarBlack
24cc4eec2006HondaGreen
518263ae1999FiatWhite
153b67471977BMWWhite
6a6cd7e71982FiatBlue
<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>