| Author |
Problems using h:selectOneMenu
|
Jeremiah Lopez
Greenhorn
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? Thanks, Jeremiah [ March 30, 2008: Message edited by: Jeremiah Lopez ]
|
 |
Alexander Bell
Greenhorn
Joined: Mar 31, 2008
Posts: 7
|
|
Hi, 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="http://www.j4fry.org" target="_blank" rel="nofollow">http://www.j4fry.org</a>
|
 |
Jeremiah Lopez
Greenhorn
Joined: Mar 30, 2008
Posts: 2
|
|
|
Yeah, I figured that out yesterday. I tried using a Map and presto, it worked!
|
 |
Jesus Carrillo
Greenhorn
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" value="#EngineSeriesSearchBean.engineSeriesValues}"/> </h:selectOneListbox> 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>(); values.put("",""); 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
Greenhorn
Joined: May 03, 2004
Posts: 7
|
|
|
I don't see a setter for the it.
|
 |
 |
|
|
subject: Problems using h:selectOneMenu
|
|
|