0 Replies Latest reply on Apr 25, 2008 10:42 AM by shiocaltz

    scrollableDataTable index out of bounds exception

      given the following example:
      the .jspx page

      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
       xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:jxee="http://www.jxee-lab.ro/jsf"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:t="http://myfaces.apache.org/tomahawk">
       <h:form id="scrollableDataTableForm">
       <rich:scrollableDataTable id="scrollableDataTable" var="tableVar"
       rows="10" eventsQueue="testQueue" value="#{test.testObjects}">
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Name" />
       </f:facet>
       <h:outputText value="#{tableVar.guiLabel}" />
       </rich:column>
       </rich:scrollableDataTable>
       </h:form>
       <h:form>
       <h:panelGrid columnClasses="3">
       <a4j:commandLink action="#{test.populateWith2Elements}"
       value="set 2 elements" eventsQueue="testQueue"
       reRender="scrollableDataTable" />
       <a4j:commandLink action="#{test.populateWith1Element}"
       value="set 1 element" eventsQueue="testQueue"
       reRender="scrollableDataTable" />
       <a4j:commandLink action="#{test.submit}" value="Simple submit"
       eventsQueue="testQueue" />
       </h:panelGrid>
       </h:form>
      </jsp:root>
      
      


      and java code:
      package ro.jxeelab.erp.client.jsf.payroll.common.adapters;
      
      import java.util.ArrayList;
      import java.util.List;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.richfaces.model.impl.ListDataModel;
      
      @Name("test")
      @Scope(ScopeType.PAGE)
      public class Test {
       private ListDataModel testObjects = null;
      
       public ListDataModel getTestObjects() {
       return testObjects;
       }
      
       public void setTestObjects(ListDataModel testObjects) {
       this.testObjects = testObjects;
       }
      
       public void populateWith1Element() {
       List<TestObject> list = new ArrayList<TestObject>();
       TestObject testObject = new TestObject();
       testObject.setGuiLabel("setElement1->element1");
       list.add(testObject);
      
       testObjects = new ListDataModel(list);
       }
      
       public void populateWith2Elements() {
       List<TestObject> list = new ArrayList<TestObject>();
       TestObject testObject = new TestObject();
       testObject.setGuiLabel("setElement1->element1");
       list.add(testObject);
       testObject.setGuiLabel("setElement1->element2");
       list.add(testObject);
      
       testObjects = new ListDataModel(list);
       }
      
       public void submit() {
       System.out.println("submit action");
       }
      
      }
      
      

      
      package ro.jxeelab.erp.client.jsf.payroll.common.adapters;
      
      public class TestObject {
      
       private String guiLabel;
      
       public String getGuiLabel() {
       return guiLabel;
       }
      
       public void setGuiLabel(String guiLabel) {
       this.guiLabel = guiLabel;
       }
      }
      
      
      


      on the environment:
      jbos 4.2, richFaces 3.2.0/3.2.0.SR1, seam 2.0.GA, facelets, ejb 3.0

      will cause a "index out of bounds exception" if the buttons are clicked on the follwing order:
      set 2 elements
      set 1 element
      Simple submit

      The reason is that the scrollableGrid keeps track of the sizez of the list, which are applied to the last state of the rows. So on the third sumbit the grid will have a list containg the row sizes with the following states:

      0 2
      0 1
      applied on a list containing a single row, causing the exception.

      Maybe i am doing something wrong, therefore i would like to have your opinion on wether it is a bug or not.
      The workaround that i found is to rerender the scrollable grid as well. But this is only a temporary sollution for me until i hear from you. I do not want to rerender the grid every time i have a submit after the sequence above/
      Happy Easter and hope to hear soon from you :)