I am trying to iterate over a collection of elements, which are complex types (another entities) using <c:forEach>
:
<c:forEach items="#{repcatTree.items}" var="item">
<div style="padding-top:7px; padding-bottom:7px; padding-right:15px;">
<span class="report_item_category_class">
<h:commandLink rendered="#{item.type == 'category'}" action="#{item.onNodeClicked}" styleClass="default_link">
<h:graphicImage url="/views/tree/images/folder_big.gif" />
<h:outputText value="#{item.attributes.FILE_NAME}" style="font-size:14px; font-weight:bold; padding-left:5px" />
</h:commandLink>
<h:commandLink rendered="#{item.type == 'report'}" styleClass="default_link" action="action_report_run" title="#{item.cells['report_name'].toolTip}">
<h:graphicImage url="/icon?rdd_path=#{item.attributes.RDD_PATH}" />
<h:outputText value="#{item.cells['report_name'].display}" style="font-size:14px; font-weight:bold; padding-left:5px" />
<f:param name="nodePath" value="#{item.attributes.RDD_PATH}" />
<f:param name="nodePrettyPath" value="#{item.attributes.CAT_PATH}" />
</h:commandLink>
</span>
</div>
</c:forEach>
However, inside of forEach block logic treats '#{item}' element as a regular java.lang.String
causing
javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'type'.
Here's my faces-config.xml
(JSF 1.2) related mapping entry:
<managed-bean>
<managed-bean-name>repcatTree</managed-bean-name>
<managed-bean-class>rpt.engine.runner.tree.impl.RepcatTreeModel</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>path</property-name>
<property-class>java.lang.String</property-class>
<value>/</value>
</managed-property>
<managed-property>
<property-name>listener</property-name>
<property-class>rpt.engine.runner.tree.listeners.ReportsTreeModelListener</property-class>
<value>#{reportsTreeModelListener}</value>
</managed-property>
<managed-property>
<property-name>tableModel</property-name>
<property-class>rpt.engine.runner.table.TableModel</property-class>
<value>#{repcatTableModel}</value>
</managed-property>
</managed-bean>
How is this caused and how can I solve it?
That can happen if you used the wrong JSTL version for the environment or used the wrong JSTL taglib URI declaration.
JSF 1.2 implies a minimum of Servlet 2.5 (your webapp's
web.xml
must also be declared as such!), which in turn implies a minimum of JSTL 1.2, which in turn implies a taglib URI ofhttp://java.sun.com/jsp/jstl/core
.Make sure you got everything right. Your particular problem is caused because
#{repcatTree.items}
is not interpreted as an EL expression, but instead as plain string, indicating that EL in JSTL doesn't work at all, which in turn indicates that you're possibly using JSTL 1.0/1.1 (note that Glassfish already bundles JSTL, so you should not ship any along with your webapp), or used the JSTL 1.0 taglib URI without the/jsp
path, or theweb.xml
is not declared conform Servlet 2.5.See also: