0 Replies Latest reply on Jun 7, 2011 3:12 AM by Faisal Basra

    Problem with h:selectOneMenu and a4j:support

    Faisal Basra Newbie

      Hi, I have some problem with h:selectOneMenu. There is dependent component on h:selectOneMenu which and h:selectOneMenu is mandatory that's why marked required=true.

       

      Problem is when user select, default label i.e. "Please Select" which holds null value, the validation occurs and fails and method is not being called. Please suggest me how to fix this proble.

       

      <h:selectOneMenu id="planets" value="#{planetsMoons.currentPlanet}" valueChangeListener="#{planetsMoons.planetChanged}" required="true">

              <f:selectItems value="#{planetsMoons.planetsList}" />

              <a4j:support event="onchange" reRender="moon" />

      </h:selectOneMenu>

       

      <h:outputText id="moon" value="#{planetsMoons.moon}">

       

       

             public List<SelectItem>  getPlanetsList(){

         

               // For Select

              SelectItem item = new SelectItem();

              item.setValue(null);

              item.setLabel("Please Select");

              itemList.add(item);

       

              // Industrial Classification from DB

              List<Plant> plantList =  this.plantDAO.findAll();

       

       

                  for (Plant plant: plantList) {

                      item = new SelectItem();

                      item.setValue(plant.getCode());

                      item.setLabel(plant.getName);

                      itemList.add(item);

                  }

                }