我正在尝试迭代一组元素,这些元素是复杂类型(另一个实体),使用<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>
但是,在 forEach 块逻辑内部将 '#{item}' 元素视为常规java.lang.String
原因
javax.el.PropertyNotFoundException:类'java.lang.String'没有属性'type'。
这是我的faces-config.xml
(JSF 1.2)相关映射条目:
<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>
这是如何引起的,我该如何解决?