Hi Faisal,
I had the same problem, it was because my Backing Bean has
request scope, and my list was not initialized in the constructor
method.
The problem was, that as the Backing Bean did not have the
list initialized the "value" of the component was not set.
An easy way to detect this problem is to be sure that
your JSP page has somewhere the tag h:messages.
<h:messages showDetail="table" layout="table"/>
Hope this helps
tonio
On Mon, 2006-06-05 at 11:48 -0700, Faisal Mahmoud wrote:
> Hi All,
>
> I am building a drop down list using the <h:selectOneMenu> tag and all
> the items in the List populate and show up correctly in the drop down
> list. But after the user selects an item in the list and submits the
> form, when I check the property that is specified in the tag's value
> attribute, I get a NullPointerException. My code is below:
>
>
> jsp page:
> <h:selectOneMenu id="selectFromExistingTenants" immediate="true"
> value="#{SelectNewControlDeviceTypePage.chosenDevice}">
> <f:selectItems
> value="#{SelectNewControlDeviceTypePage.licensedDevices}"/>
> </h:selectOneMenu>
>
> Code that builds the java.util.List of javax.faces.model.SelectItem
> objects in the <f:selectItems> value attribute:
> List list = this.licensedControllerDAO.getAllLicensedControllers();
> logger.debug("Retrieved List of LicensedController objects. List size
> = " + list.size());
> Iterator iter = list.iterator();
> while (iter.hasNext())
> {
> LicensedController licensedController = (LicensedController)
> iter.next();
> String controllerLabel = licensedController.getLabel();
> SelectItem selectItem = new SelectItem(controllerLabel,
> controllerLabel);
> licensedDevices.add(selectItem);
> logger.debug("Added a SelectItem to the List with controllerLabel
> = " + controllerLabel);
> }
>
>
> Backing Bean code for the <h:selectOneMenu> tag's value attribute:
> //SelectNewControlDeviceTypePage.java
> private String chosenDevice;
> // PROPERTY: chosenDevice
> public String getChosenDevice() { return this.chosenDevice; }
> public void setChosenDevice(String chosenDevice) { this.chosenDevice
> = chosenDevice; }
>
>
> So what am I doing wrong in my code such that my backing bean property
> is not getting with the chosen item?
>
> Faisal Mahmoud
> www.quidprocode.com
>