Mohit224
Mohit224

Reputation: 493

JSF selectOneMenu tag error while using a list

I am using JSF tag h:selectOneMenu for a drop down List.

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

The subList object is a list which I have defined in my bean class with getter and setters. In my init method of my servlet I am populating the list with some values. But when I am loading the page I am getting the following error:

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

Not able to understand what is causing the problem.

Upvotes: 2

Views: 4089

Answers (1)

BalusC
BalusC

Reputation: 1108972

The exception is rather self-explaining.

java.lang.IllegalArgumentException: Collection referenced by UISelectItems (...) does not contain Objects of type SelectItem

The #{manageSubscriberInformation.subList} must return a List<SelectItem> or SelectItem[] where SelectItem is the javax.faces.model.SelectItem class.

Only since JSF 2.0, it is not required anymore to be specifically SelectItem.

See also:

Upvotes: 2

Related Questions