2 Replies Latest reply on Aug 10, 2011 8:08 AM by Kapil Nimje

    ValueChangeEvent  causing problem?

    Kapil Nimje Newbie

      I have the Rich Data table which contains the two drop down one for "Status" and other for the "Size" in the

      columns. I have two separate valuechange listener method i.e. statusChangedListener(ValueChangeEvent event) and

      sizeChangedListener(ValueChangeEvent) which invokes when any of the values are changing from any of those two drop

      down respectively.

       

      Now, what i am facing the issue is... When i change any of the status from the "Status" drop down in the rich

      datatable, my statusChangedListener() method is invoked that is correct but after completing execution of that

      method, the system internally invoked other listener method i.e sizeChangedListener() that is wrong even if i am

      not changing anything frm the "Size" drop down. As my size changed listener will invoked when i change anything

      from the size drop down.

       

      Please find the below code

       

      <rich:datatable>

      ....

        <rich:column id="statusColumn"

                        filterMethod="#{projectFilterBean.filterProjectTable}"

                        filterValue="#{projectFilterBean.filterValue}"

                        sortBy="#{project.status.description}">

       

              <f:facet name="header"><h:outputText value="Status"/></f:facet>

       

                      <h:selectOneMenu id="test" value="#{project.status}"

                                         converter="#{statusConverter}"

                                        valueChangeListener="#{projectController.projectStatusChanged}"

                                        styleClass="statusSelector" immediate="true">

       

                          <f:selectItems value="#{projectController.existingStatusSelectItems}"/>

       

                          <a4j:support event="onchange" reRender="data_table,data_scroller" status="waitStatus" />

       

                      </h:selectOneMenu>

      </rich:column>

       

      <rich:column id="dimensionColumn"

                        filterMethod="#{projectFilterBean.filterProjectTableWithSize}"

                        filterValue="#{projectFilterBean.filterSizeValue}"

                        sortBy="#{project.dimension.widthAndHeight}">

       

               <f:facet name="header"><h:outputText value="Size"/></f:facet>

       

                       <h:selectOneMenu value="#{project.dimension}"

                                        converter="#{dimensionConverter}"

                                        valueChangeListener="#{projectController.sizeChanged}"

                                        styleClass="dimensionSelector">

       

                          <f:selectItems value="#{projectController.existingDimensionSelectItems}"/>

       

                      </h:selectOneMenu>

           </rich:column>

      ..

      </rich:datatable>

       

       

      Java Code

       

      public void sizeChanged(ValueChangeEvent event) {

       

              try {

       

                  Project selectedProject = (Project) getProjectDataTable().getRowData();

                   Dimension oldDimension = selectedProject.getDimension();

                   Dimension selectedDimension = (Dimension) event.getNewValue();

      ....

       

          //     doing some business logic over here

      ....

             }

      }

       

       

      public void projectStatusChanged(ValueChangeEvent event) {

       

              try {

                   Project selectedProject = (Project) getProjectDataTable().getRowData();

                   Status oldStatus = selectedProject.getStatus();

                   Status selectedStatus = (Status) event.getNewValue();

                   if (selectedStatus != null) {

                       selectedProject.setStatus(selectedStatus);

                       selectedProject.setUpdatedAt(new Timestamp(System.currentTimeMillis()));

       

                       if (selectedStatus.getName().equals("PROJECT_ACTIVE")) {

                           if (selectedProject.getActivatedAt() == null) {

                               selectedProject.setActivatedAt(new Timestamp(System.currentTimeMillis()));

                           }

       

                          selectedProject.setDeletable(false);

       

                      }

       

                      selectedProject.setXmlUpdate(true);

       

                      if(projectService.updateWithReturn(selectedProject))

       

                          logger.debug(selectedProject + "Status changed from " + oldStatus.getDescription() + " to " +

                          selectedStatus.getDescription());

                  }

       

              } catch (Exception ex) {

       

                  logger.error(ex.getMessage());

       

              }

           }

       

       

      Kindly help me to sort out this issue, as we are having this serious issues on our production application.

       

      Please find the attached form contains the rich Datatable.