I'm iterating over a list of entities, rendering some links with specific icons. I'd like to conditionally set a class
attribute value during the iteration based on the currently active lesson as below, so that the "active" item gets a different style:
<ui:repeat value="#{lessonBean.allLessons}" var="lesson">
<li>
<h:form>
<h:commandLink>
<i class="#{lessonBean.currentLesson == lesson ? 'green' : ''}" />
</h:commandLink>
</h:form>
</li>
</ui:repeat>
It only doesn't seem to ever return true
on the comparison and thus green
is never printed. I've searched for examples and found some solutions using #{view.viewId}
, but this doesn't suit my requirement.
How can I achieve my requirement?