File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Problems using h:selectOneMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Problems using h:selectOneMenu" Watch "Problems using h:selectOneMenu" New topic

Problems using h:selectOneMenu

Jeremiah Lopez

Joined: Mar 30, 2008
Posts: 2
I've been fighting JSF for a few days now on how to create a drop-down list based on static values. This will be a list where the user will only select one item. I'm getting exceptions when I navigate to the page that is using this control and I'm not exactly sure why, hence the reason for my post. These are JSF pages that are deployed in JBoss Portal 2.6.3.

In my faces-config.xml, I have the following entry:

Here is the CustomerBean class:

Here is where I'm setting up the component in the JSF file and referencing the CustomerBean:

And here's the lovely exception that I get once I navigate to the page:

That doesn't make any sense to me. I am explicity adding objects of type SelectItem to the list, so why would it say that objects are not of type SelectItem?

[ March 30, 2008: Message edited by: Jeremiah Lopez ]
Alexander Bell

Joined: Mar 31, 2008
Posts: 7

i don't try that with an array of selectItems.

you can try to use a map (e.g. a HashMap) to deliver the values.
The keys are the lables on the HTML-Page an the values are the values for the bean-property.

You should also define the attribute "value" in the selectOneMenu-Tag.

mfg alex

Visit <a href="" target="_blank" rel="nofollow"></a>
Jeremiah Lopez

Joined: Mar 30, 2008
Posts: 2
Yeah, I figured that out yesterday. I tried using a Map and presto, it worked!
Jesus Carrillo

Joined: Aug 01, 2008
Posts: 1
I tried using a Map but still getting:

java.lang.IllegalArgumentException: Value binding of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/engineSeriesSearch.jsp][Class: javax.faces.component.html.HtmlForm,Id: _idJsp0][Class: javax.faces.component.html.HtmlSelectOneListbox,Id: engineSeriesNum][Class: javax.faces.component.UISelectItems,Id: availableEngines]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null

My JSP is:

<h:selectOneListbox id="engineSeriesNum">
<f:selectItems id="availableEngines"

and code in my bean

public class EngineSeriesSearchBean
private Map<String,String> engineSeriesValues;

public EngineSeriesSearchBean(){}

public Map<String,String> getEngineSeriesValues()
Map<String,String> values = new HashMap<String,String>();

for(int i=0; i<=5;i++)
values.put(String.valueOf(i), String.valueOf(i));
engineSeriesValues = values;
return engineSeriesValues;

public void setEngineSeriesValues(Map<String,String> values)
engineSeriesValues = values;

any idea of why Map didn't not work?
Qarabagi Jaan

Joined: May 03, 2004
Posts: 7
I don't see a setter for the it.
I agree. Here's the link:
subject: Problems using h:selectOneMenu
It's not a secret anymore!