【问题标题】:JSF selectOneMenu tag error while using a list使用列表时 JSF selectOneMenu 标记错误
【发布时间】:2012-03-07 23:47:07
【问题描述】:

我正在使用 JSF 标记 h:selectOneMenu 作为下拉列表。

<h:selectOneMenu id="subscriberName" value="#{manageSubscriberInformation.subscriberName}" 
    <f:selectItem itemValue="" itemLabel="" />                            
    <f:selectItems value="#{manageSubscriberInformation.subList}" />
</h:selectOneMenu> 

subList 对象是我在我的 bean 类中使用 getter 和 setter 定义的列表。 在我的 servlet 的 init 方法中,我用一些值填充列表。 但是当我加载页面时,我收到以下错误:

java.lang.IllegalArgumentException: Collection referenced by UISelectItems with binding '#{manageSubscriberInformation.subList}' and Component-Path : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /jsp/manageSubscriber.jsp][Class: javax.faces.component.UINamingContainer,Id: body][Class: javax.faces.component.html.HtmlForm,Id: c][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: subscriberName][Class: javax.faces.component.UISelectItems,Id: _idJsp143]} does not contain Objects of type SelectItem

无法理解导致问题的原因。

【问题讨论】:

    标签: jsf selectonemenu


    【解决方案1】:

    这个例外不言自明。

    java.lang.IllegalArgumentException:UISelectItems (...) 引用的集合不包含 SelectItem 类型的对象

    #{manageSubscriberInformation.subList} 必须返回 List&lt;SelectItem&gt; 或 SelectItem[],其中 SelectItem 是 the javax.faces.model.SelectItem class。

    仅从 JSF 2.0 起,不再需要专门为 SelectItem。

    另见:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-29
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 2013-08-04
      • 1970-01-01
      • 2011-11-03
      相关资源
      最近更新 更多