• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to get SelectedItems in the h:selectOneMenu

 
tony altaico
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

As you will see below, I have h:selectOneMenu which I get data from jave beans. Unfortunately I come across with the following error when I implemneted h:selectOneMenu. I think there is something wrong with my f:selectedItems value as I implemented it as ArrayList<SelectItem> in java.. Can you please check the error and java and xhtml implementation of my code and give me tips about the error ?

Error :

Collection referenced by UISelectItems with binding '#{collection.statusDescriptionMap}' and Component-Path : {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /outboundDialer.xhtml][Class: org.richfaces.component.html.HtmlTabPanel,Id: _id2][Class: org.richfaces.component.html.HtmlTab,Id: _id3][Class: javax.faces.component.html.HtmlForm,Id: LoginForm1][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: statusDescription][Class: javax.faces.component.UISelectItems,Id: _id10]} does not contain Objects of type SelectItem

XHTML implementation :



Java implementation :


 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a conflict here. You say that you implemented your selectedItems as an ArrayList<SelectItem>, but your getProperty method returns a List<String>, instead.

SelectOneMenu cannot use a String collection as its model because each generated OPTION element has 2 items: the value and the label. Although SelectItem has a constructor that can take only one parameter, it's simply a convenience method that sets the label and optionvalue to the same value, so the selectOneMenu can use a simple standard model architecture instead of having to play games.
 
tony altaico
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim .. It has been resolved ..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!