1 Reply Latest reply on Jul 31, 2011 7:49 PM by Andrew Dambrosio

    Datatable not updating when clicking on commandlink

    Andrew Dambrosio Newbie

      I have a datatable with a column that contains an up arrow and another column that has a down arrow. These allow you to move the row up and down. However, when I click on them, the moveUp method in the bean is triggered and the order is updated, but I don't see this in my browser. When I trigger it again, I can tell (with printlns) that the order is reset to what was originally retrieved from the database.

      Below is an extract of my JSP and bean. Please help


      <h:panelGrid id="pgPage" columns="1" width="100%">

           <rich:dataTable binding="#{MyBean.staffTable}" value="#{MyBean.staffList}" var="staff"

                                                          rowClasses="row1, row2" id="staffTable" rows="20"





                                                          <f:facet name="header">


                                                                  <rich:column width="27%">

                                                                      <h:outputText value="Name" />


                                                    <rich:column width="10">

                                                                      <h:outputText value="Up" />





                                                              <h:outputText value="#{staff.staffname}" />




                                                             <a4j:commandLink reRender="pgPage" actionListener="#{MyBean.moveUp}">

                                                                  <h:graphicImage url="/images/move_up.png" style="border:0;width:15px;height:15px;"/>










      public class MyBean extends AbstractPageBean {

           private org.richfaces.component.html.HtmlDataTable staffTable = new org.richfaces.component.html.HtmlDataTable();

          public org.richfaces.component.html.HtmlDataTable getStaffTable() {

              return staffTable;


          public void setStaffTable(org.richfaces.component.html.HtmlDataTable hot) {

              this.staffTable = hot;





           public void moveUp(ActionEvent e) throws Exception {

              try {

                  int selectedIndex = staffTable.getRowIndex();

                  WWWWebsiteStaff selectedStaff = (WWWWebsiteStaff) staffTable.getRowData();

                  if (selectedIndex == 0) {

                      //do nothing

                  } else {


                      staffList.add(selectedIndex - 1, selectedStaff);


              } catch (Exception ex) {



              staffList = getStaffList();