1 Reply Latest reply on Apr 3, 2012 3:03 AM by mtranchant

    RF4 : selectOneMenu + ajax : cannot get the selectedValue in Bean

    mtranchant Newbie

      Hi everybody,

       

      I started a user-interface using RichFaces4.1.Final.

      I face my first issue...

       

      In my JSF I have this code :

      <h:selectOneMenu value="#{mainController.selectedCubeUniqueName}" id="cubeSelection">

          <f:selectItems value="#{mainController.cubeNameList}" />

          <a4j:ajax event="change" listener="#{mainController.cubeChanged}" render="dimensions" ajaxSingle="true" />

      </h:selectOneMenu>

       

      In my bean  "mainController"

       

      public void cubeChanged(AjaxBehaviorEvent abe)

      {

       

           String cubeRequested = selectedCubeUniqueName;

           System.out.println("cubeChanged cubeRequested: " + cubeRequested);

           System.out.println("cubeChanged: " + ((HtmlSelectOneMenu) abe.getComponent()).getSubmittedValue());

      }

       

      When changing the value in the select, the console output is:

           cubeChanged cubeRequested:

           cubeChanged abe: null

       

      My question is: how I get the selected value in my selectOneMenu through an Ajax call ?

       

      Thanks in advance

      Regards

       

      Ce message a été modifié par: mtranchant

        • 1. Re: RF4 : selectOneMenu + ajax : cannot get the selectedValue in Bean
          mtranchant Newbie

          I have found a solution

           

          JSF:

          <h:form id="cubeChoice">

              <h:selectOneMenu value="#{mainController.selectedCubeUniqueName}" id="cubeSelection">

                  <f:selectItems value="#{mainController.cubeNameList}"/>

                  <a4j:ajax event="change" listener="#{mainController.cubeChanged}" ajaxSingle="true" execute="@this" render="dimensions" />

              </h:selectOneMenu>

              <rich:message for="cubeSelection" />

          </h:form>

           


           

           

          The value is correctly transfered to the bean in  selectedCubeUniqueName

          public void cubeChanged(AjaxBehaviorEvent abe)

          {

            // this.selectedCubeUniqueName

          }

           


           

          Regards

          Michael