1 Reply Latest reply on Dec 8, 2011 3:49 AM by kh.ramana

    a4j:ajax with h:selectOneMenu problem

    kh.ramana

      I have been using the below code... When I select the value from the selectOneMenu the valueChangeListener is calling, but the selected value fromthe drop-down is not going at the time of call

       

      For Ex: If we think dropdown values are (A,B,C,D)... Initally the value will be A.... when i change the value to C.. the listener is called at this point of time the value to the java class is passed as A only instead of the selected value C.... If we select the value D.. the value to the java class will be C... mean to say the previous value is going to the JAVA class....

       

       

      <h:selectOneMenu defaultLabel="A" valueChangeListener="#{timeSheetReportBean.loadMembers}"

                    value="#{timeSheetReportBean.timesheetReportDto.locationId}"

                   id="location" style="width:140px;">

                           <f:selectItems value="#{timeSheetReportBean.locationList}" />

                                                        <a4j:ajax render="members" event="valueChange" execute="@this" />

            </h:selectOneMenu>

       

       

      <h:selectManyListbox id="members" size="6"

                                                        value="#{timeSheetReportBean.timesheetReportDto.memberIds}" style="width:140px;">

                                                        <f:selectItems value="#{timeSheetReportBean.members}" />

                                              </h:selectManyListbox>

       

      Can any one help me on this.....

        • 1. Re: a4j:ajax with h:selectOneMenu problem
          kh.ramana

          public void loadMembers(ValueChangeEvent event) {

           

                              System.out.println(" event " + event.getNewValue());

          }

           

           

          UI is fine..but i made an mistake in Java class......... the methos should contain the parameter as ValueChangeEvent.

           

          Now we can set the value of event.getNewValue() to any required variable.....