【发布时间】:2010-06-23 18:25:39
【问题描述】:
将每个订单一个位置的工作表单修改为每个订单多个位置我在预填充 h:selectOneMenu 时遇到了问题。例外是java.lang.IllegalArgumentException: Value binding '#{spot.deliveryTypes}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /order.jsp][Class: javax.faces.component.html.HtmlForm,Id: pf][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: _idJsp11][Class: javax.faces.component.UISelectItems,Id: _idJsp12]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null
旧的工作 JSP 代码:
<h:selectOneMenu value="#{order.deliveryType}" immediate="true">
<f:selectItems value="#{order.deliveryTypes}" />
</h:selectOneMenu>
新的不工作的 JSP 代码:
<c:forEach var="spot" items="${order.spots}">
<h:selectOneMenu value="#{spot.deliveryType}" immediate="true">
<f:selectItems value="#{spot.deliveryTypes}" /> <%-- Works as empty list if this line removed --%>
</h:selectOneMenu> <c:out value="${spot.name}"/><br/>
</c:forEach>
引入了新字段List<Spot> spots 以及getter 和setter。 List<SelectItem> getDeliveryTypes() 已从托管 bean 类 Order 移至 Spot 类。
如何访问 spot.deliveryTypes?将 # 更改为 $ 没有帮助,因为 value= 不接受 EL。
MyFaces 1.1.8
谢谢。
【问题讨论】: