I have a bean with a field status. Depending on the value status, a different css class must be used to render it.
So, I need something like this (very far from the pseudo-exchange of real things):
if status == "Approved"
cssClass = "green"
if status == "Rejected"
cssClass = "red"
<span class="cssClass">Some info</span>
I tried to apply jstl, but I can not get it to work with facelets and jsf (but I heard that this is possible, maybe its true). Here is the code:
<c:choose>
<c:when test="#{report.approved}">
<c:set var="statusClass" value="approved"/>
</c:when>
<c:when test="#{report.rejected}">
<c:set var="statusClass" value="rejected"/>
</c:when>
<c:when test="#{report.inProgress}">
<c:set var="statusClass" value="progress"/>
</c:when>
<c:when test="#{report.pendingHR}">
<c:set var="statusClass" value="pending"/>
</c:when>
</c:choose>
<span class="status ${statusClass}">#{report.formattedStatus}</span>
How to do this with JSF / Facelets?
source
share