Reputation: 3893
I am trying to iterate through Collection of items:
<c:forEach items="#{tree.items}" var="item">
<h:commandLink rendered="#{item.type == 'category'}" action="#{item.onNodeClicked}"
Hovewer, i've got an exception:
javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'type'.
Looks like JSP recognizes tree items as String objects. What i am missing?
Upvotes: 1
Views: 297
Reputation: 1108632
This is not going to work. The #{item}
is only available during view build time, while the rendered
attribute is evaluated during view render time.
Use <c:if>
instead.
<c:forEach items="#{tree.items}" var="item">
<c:if test="#{item.type == 'category'}">
<h:commandLink ... action="#{item.onNodeClicked}" />
Or, if you're on JSF2 (which is out for more than 3 years), replace that legacy JSP by its successor Facelets and use its <ui:repeat>
component instead. It's evaluated during view render time as well.
<ui:repeat value="#{tree.items}" var="item">
<h:commandLink rendered="#{item.type == 'category'}" action="#{item.onNodeClicked}" />
Upvotes: 1