1 Reply Latest reply on May 27, 2008 8:59 AM by konstantin.mishin

    ScrollableDataTable: problems with selection while scrolling

    opr

      Hi there,

      we are using Richfaces 3.2.0

      We implemented a page consisiting of a scrollableDataTable.

       <rich:scrollableDataTable
       sortMode="single"
       rows="20"
       id="consultantTable"
       selectedClass="tableSelection"
       value="#{consultantBean.consultantModel}"
       var="consultant"
       height="120px"
       hideWhenScrolling="false"
       binding="#{consultantBean.htmlScrollableDataTable}"
       rowKeyVar="rkv"
       selection="#{consultantBean.selectedRows}">
      
       <rich:column headerClass="tableHeader" sortable="false">
       <h:outputText value="#{rkv}"/>
       </rich:column>
       <rich:column headerClass="tableHeader" sortable="false">
       <f:facet name="header">
       <h:outputText value="#{i18n.general_lbName}"/>
       </f:facet>
       <h:outputText value="#{consultant.givenname} #{consultant.surname}"/>
       <f:facet name="footer">
       <h:inputText style="width:100%;font-size: 0.8em" id="filterName" value="#{consultantBean.filterName}"/>
       </f:facet>
       </rich:column>
       <rich:column headerClass="tableHeader" sortable="false">
       <f:facet name="header">
       <h:outputText value="#{i18n.general_lbPhone}"/>
       </f:facet>
       <h:outputText value="#{consultant.contact.phone}"/>
       <f:facet name="footer">
       <h:inputText style="width:100%;font-size: 0.8em" id="filterPhone" value="#{consultantBean.filterPhone}"/>
       </f:facet>
       </rich:column>
       <rich:column headerClass="tableHeader" sortable="false">
       <f:facet name="header">
       <h:outputText value="#{i18n.general_lbMail}"/>
       </f:facet>
       <h:outputText value="#{consultant.contact.mail}"/>
       <f:facet name="footer">
       <h:inputText style="width:100%;font-size: 0.8em" id="filterMail" value="#{consultantBean.filterMail}"/>
       </f:facet>
       </rich:column>
       <rich:column headerClass="tableHeader" id="address" sortable="false">
       <f:facet name="header">
       <h:outputText value="#{i18n.general_lbAdress}"/>
       </f:facet>
       <h:outputText value="#{consultant.address.street}, #{consultant.address.zip} #{consultant.address.city}"/>
       <f:facet name="footer">
       <h:inputText style="width:100%;font-size: 0.8em" id="filterAddress" value="#{consultantBean.filterAddress}"/>
       </f:facet>
       </rich:column>
       <a4j:support event="onselectionchange" reRender="details,action" actionListener="#{consultantBean.selectionChanged}">
       </a4j:support>
       </rich:scrollableDataTable>
      


      Selection is working fine. For debugging purposes we included the row key variable in the first column.

      In the backing bean we can see the correct key when selecting a row in the table.

      public void selectionChanged(ActionEvent e) throws AbortProcessingException
       {
       HtmlScrollableDataTable table = (HtmlScrollableDataTable) ((HtmlAjaxSupport) e.getComponent()).getParent();
       Selection sel = selectedRows;
      
      
       System.out.println(selectedConsultantId);
      
       if (sel != null)
       {
       Iterator i = sel.getKeys();
      
       if (i.hasNext())
       {
       SimpleRowKey key = (SimpleRowKey)i.next();
      
       table.setRowKey(key);
      
       System.out.println("Key: " + key.intValue());
       Consultant cons = (Consultant)table.getRowData();
       System.out.println(cons.getSurname());
      
       Consultant c = (Consultant)getConsultantModel().getConsultants().get(key.intValue());
      
       consultant = cons;
      
       if (c.getAddress() != null)
       address = c.getAddress();
      
       if (c.getContact() != null)
       contact = c.getContact();
      
       deleteDisabled = false;
       editDisabled = false;
      
       Lang lang = consultant.getLang();
       if (lang != null)
       communicationLanguage = consultant.getLang().getId();
       else
       communicationLanguage = null;
       }
       }
       else
       {
       resetView();
       }
       }
      


      But when scrolling through the data, keys seem to be shuffeled which leads to inconsistent data. The selection in the table does not show the entity which is determined in the action method.

      Is there a workaround for my problem?
      What function has the rowKeyConverter-Attribute?

      RichFaces 3.2.1-SNAPSHOT does not solve the problem.

      Please help!

      Many Thanks