DataTable - Color

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

IdYearBrandColor
58d0458d2003RenaultWhite
7bdb76792008MercedesBlack
34ffe4dd1998VolvoWhite
cafccd691964BMWRed
60f525571968JaguarMaroon
12127bec1981FordBlue
cf4b88922005JaguarSilver
d59290661970VolkswagenRed
59d5a5111979RenaultBlack
e6bc78de2008FordBlue
<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>