DataTable - Color

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

IdYearBrandColor
00f9842b2007HondaOrange
e93ddda21983HondaRed
5af7b8e61995FordBlack
6d903f351989MercedesMaroon
f426a6241964MercedesYellow
3320e2701986FordMaroon
8ff9c1521975BMWRed
2794016b1986VolkswagenWhite
567837921993AudiBrown
9c6877731978JaguarYellow
<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>