2

ドロップダウン リストに JSF タグ h:selectOneMenu を使用しています。

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

subList オブジェクトは、getter と setter を使用して Bean クラスで定義したリストです。サーブレットの 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

何が問題を引き起こしているのか理解できません。

4

1 に答える 1

2

例外はかなり自明です。

java.lang.IllegalArgumentException: UISelectItems (...) によって参照されるコレクションには、SelectItem 型のオブジェクトが含まれていません

はaまたはwhereがclass#{manageSubscriberInformation.subList}を返す必要があります。List<SelectItem>SelectItem[]SelectItemjavax.faces.model.SelectItem

JSF 2.0 以降、特にSelectItem.

以下も参照してください。

于 2012-03-08T00:00:07.940 に答える