3 Replies Latest reply on Apr 22, 2008 7:58 PM by Robert Stone

    selectOneMenu fails to bind value

    Robert Stone Newbie

      Hi guys,

      I have a problem with pretty simple case of two selectOneMenu dropdowns. I'm using exposed model pattern so the first dropdown is bind to the model object with converter provided. Second dropdown contains only two hardcoded values - Active and Inactive, and bound to the 'Status' property of the model object. The problem is, when I select value from the first list, the second one will always receive Null for a value and hence 'Active" option is always displayed. If I replace second dropdown with just a text field, the 'Status' property will be properly bound to whatever value was extracted from the db.
      It seems that 'Status' property of the model object gets overwritten during binding phase if I try to bind it to the SelectOneMenu value.

      So here's stripped down version of two dropdpwns

       <h:form id="createApplicationForm">
       <h:selectOneMenu id="appList"
       value="#{applicationBean.selectedApp}"
       converter="#{namsUserConverter}">
       <f:selectItem itemValue="#{applicationBean.defaultApp}"
       itemLabel="New" />
       <f:selectItems value="#{applicationBean.apps}" />
       <a4j:support action="#{applicationBean.select}" event="onchange"
       ajaxSingle="true"
       reRender="userAppStat" />
       </h:selectOneMenu>
       <a4j:outputPanel ajaxRendered="true">
       <h:selectOneMenu id="userAppStat"
       value="#{applicationBean.selectedApp.status}">
       <f:selectItem itemLabel="Active" itemValue="A" />
       <f:selectItem itemLabel="Inactive" itemValue="I" />
       </h:selectOneMenu>
       </a4j:outputPanel>
       </h:form>
      


      Partial managed and model beans
      public class CreateApplicationBean
      {
       private List<SelectItem> apps;
       private AppUser selectedApp;
       /**
       * @return the defaultUser
       */
       public AppUser getDefaultApp()
       {
       return new AppUser();
       }
      
       public void select(){...}
      }
      
      public class AppUser
      {
       private String status;
      }
      


      Please let me know if I'm missing anything