Reputation: 159
I'm new to jsf and I can't solve this issue. I have an OutputText inside a rich:dataTable. I want to change the color of this OutputText according to its value (these values are integer). For example, if value is >= 50 then color is red, else color is white. Thanks in advance.
Upvotes: 1
Views: 15840
Reputation: 12880
It's easily done with css, for example:
...
<h:outputText styleClass="#{row.value gt 50 ? 'red' : 'white'}" value="#{row.value}"/>
...
where classes red and white are defined accordingly or directly with style attribute:
...
<h:outputText style="color : #{row.value gt 50 ? 'red' : 'white'};" value="#{row.value}"/>
...
and even simpler markup when color/class is calculated in Java:
...
<h:outputText styleClass="#{row.volumeTag}" value="#{row.value}"/>
...
or in a custom EL function:
...
<h:outputText styleClass="#{my:categorize(row.value)}" value="#{row.value}"/>
...
Upvotes: 5