In JSF you can use EL expression to set the styleClass as follow:
<rich:column>
<h:outputText value="12" id="sumOfAllValues" styleClass="#{!t330RowItems.showSpecialField ? 'rich-table-green' : 'rich-table-cell'}"/>
</rich:column>
Now I am building the table in Java code using org.richfaces.component.html.HtmlColumn the only problem is when do this:
htmlColumn.setStyleClass("#{!t330RowItems.showSpecialField ? 'rich-table-green' : 'rich-table-cell'}");
The following HTML is generated:
<tbody id="j_id154:tb">
<tr class="rich-table-row rich-table-firstrow ">
<td class="rich-table-cell #{!t330RowItems.showSpecialField ? 'rich-table-green' : 'rich-table-cell'}" id="j_id154:0:j_id155">55</td>
</tr>
The problem is it is not evaluating the EL expression. Any ideas on how I can get it to either have rich-table-cell or rich-table-green as styleClass?
You need to set it as a fullworthy
ValueExpressioninstead of as a plain vanillaString. You can create one byExpressionFactory#createValueExpression(). You can obtain the expression factory in JSF context byApplication#getExpressionFactory().So, this should do: