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
 

Reply via email to