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

listbox help needed

David Pressick

Joined: Sep 13, 2007
Posts: 1
We are new to JSF and were wondering how we can use a listbox and retain the change in value. The page only seems to retain the default value and we can't get it to change the value of the listbox. It doesn't seem to be calling this listener and the onChange doesn't seem to actually be working. The code we're using is below. Anyone see where we're in error?

<h:selectOneListbox id="uiSelectionField" size="1" valueChangeListener="#{projectListener.uiInitialSelections}" onChange="submit()">

<f:selectItem itemValue="Environment" itemLabel="Environment"/>
<f:selectItem itemValue="Status" itemLabel="Status"/>
<f:selectItem itemValue="Priority" itemLabel="Priority"/>
<f:selectItem itemValue="Release" itemLabel="Release"/>
<f:selectItem itemValue="Issue Type" itemLabel="Issue Type"/>
<f:selectItem itemValue="Function" itemLabel="Function"/>
<f:selectItem itemValue="Module" itemLabel="Module"/>

A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
First of all onChange has to be onchange.
To capture your listbox selection, you need to provide the value attribute that maps to a backing bean's property of type String(since your itemValues are all String).
On a different note, you do not need valueChangeListener or onchange-submit unless your other components on the same page should be repopulated based on your listbox selection.
I agree. Here's the link:
subject: listbox help needed
It's not a secret anymore!