I\'d like to change the background color of rows based on a condition.
You can use JSF EL Ternary operator, as below:
rowStyleClass="#{entry.action eq X ? 'history-table-row-incomplete' : (entry.action eq Y ? 'history-table-row-error' : 'default')}"
Use the rowStyleClass
attribute of the <t:dataTable>
instead of rowClasses
. The rowStyleClass
is evaluated on a per-row basis where the var="entry"
is available, while the rowClasses
is only evaluated on a per-table basis.
<t:dataTable ... rowStyleClass="#{entry.action == 'X' ? 'history-table-row-incomplete' : (entry.action == 'Y' ? 'history-table-row-error' : 'history-table-row-default')}">