0 Replies Latest reply on May 20, 2008 2:21 PM by Robert Stone

    Non-scrollable scrollableDataTable and extended datamodel

    Robert Stone Newbie

      I had multiple posts with questions related to ability of scrollableDataTable to work with extended datamodel and, generally, ability to scroll. Since no one seem to have any answers and comments I would like to share some findings with the community.

      I'm trying to display/paginate multiple results using extended data model utilizing provided examples. Here's how my table is setup

       <rich:panel id="searchResultPanel" binding="#{deviceMasterFormBean.searchResultPanel}"
       <f:facet name="header">Device search results</f:facet>
       <rich:dataTable value="#{deviceMasterFormBean.searchResultModel}"
       var="device" height="150px" width="100%" first="0" rows="20"
       onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" rowClasses="cur">
       <a4j:support event="onRowDblClick" actionListener="#{deviceMasterFormBean.onSelectSearchResult}"
       <rich:column width="150px">
       <f:facet name="header">
       <h:outputText value="Tag #" />
       <h:outputText value="#{device.tagNumber}" />
      ***** more columns ******
       <rich:toggleControl switchToState="step1" value="Back to Search" />

      I started (as shown above) with a plain vanilla <rich:datatable/> and DeviceSearchModel that extends SerializableDataModel. The first problem I run into was with this method
       * Unused rudiment from old JSF staff.
       public void setRowIndex(int rowIndex) {
       throw new UnsupportedOperationException();

      As you can see "Unused rudimet" turned out not to be so unused. You can see from stacktrace that it is called almost immediately

      Daemon Thread [http-8080-Processor24] (Suspended (breakpoint at line 228 in DeviceSearchModel))
       DeviceSearchModel.setRowIndex(int) line: 228
       ModifiableModel.setRowIndex(int) line: 95
       HtmlDataTable(UIDataAdaptor).setRowIndex(int) line: 294
       HtmlDataTable(UIData).encodeEnd(FacesContext) line: 530

      So, naturally I changed that method to
       public void setRowIndex(int rowIndex)
       this.rowIndex = rowIndex;
       // throw new UnsupportedOperationException();

      Which makes everything work. I run the search and got results displayed. The walk() method of my custom data model was called to get the results
      Daemon Thread [http-8080-Processor24] (Suspended (breakpoint at line 93 in DeviceSearchModel))
       DeviceSearchModel.walk(FacesContext, DataVisitor, Range, Object) line: 93
       ModifiableModel.walk(FacesContext, DataVisitor, Range, Object) line: 118
       HtmlDataTable(UIDataAdaptor).walk(FacesContext, DataVisitor, Object) line: 1112
       HtmlDataTable(UIDataAdaptor).iterate(FacesContext, UIDataAdaptor$ComponentVisitor, Object) line: 1028
       HtmlDataTable(UIDataAdaptor).processDecodes(FacesContext, Object) line: 1119
       HtmlDataTable(UIDataAdaptor).processDecodes(FacesContext) line: 1129

      Now, if I just change rich:datamodel to rich:scrollableDataTable leaving setup the same, I'll get nothing. That is, walk() method of my extended data model is never called. Basically anytime getExtendedDataModel() is called, instance of DataModelCache is returned which then calls ScrollableTableDataModel#walk. So my walk() code is never executed and I get an empty table.
      Do I need to extend ScrollableTableDataModel? But then how do I wire it so it will be used instead of DataModelCache?

      If anyone has some hints - please, I really need to figure this one out since I don't want to monkey with the datatable scroller