0 Replies Latest reply on Dec 19, 2009 8:11 AM by Edilmar Alves

    Paging on-demand x filter fields + rich:dataTable

    Edilmar Alves Expert
      Hi,

      I have a RichFaces 3.3.2 page to filter data that would do this:
      1) at first time opening, to show the filter fields (initial date, final date, number of doc, etc) and a rich:DataTable that
      should be invisible, with no default data.
      2) after click "Search" button, to show the result with paging on-demand


      I implemented the logical for paging on-demand, and it works fine but my RichFaces page has some user-interface problems:

       

      1) when opening for the first time, all records from the database are showed, likewise user had clicked "Search" button. My dataTable is here:

      <rich:dataTable id="tableViagens" rows="20" var="item" 
        binding="#{consViagensCliente.htmlDataTable}"
        value="#{consViagensCliente.pageDataModel}"
        >...
      

      where:

      • htmlDataTable is a bean var to control pagination;
      • getPageDataModel() is a method to implement the filter logical + count total records + pagination of the result into a DataModel var

      The first suggestion might be check in the getPageDataModel() method if user typed some fields, if not, this is the first time, and I may return a null DataModel. However, a requisite of this page is to allow users to click "Search" without filters, and to show all results with paging.

       

      2) I don't get to use "a4j:keepAlive" at this page. When this is set, htmlDataTable always becomes null, and I don't get to make the paging. Neither at the first time when I call the page it works. Then, I understood that "binding a DataTable" doesn't work with "keepAlive"...

       

      3) Because keepAlive doesn't work, when user types some values in filter fields and clicks "Search", the first page works fine, but the others not. I think the filters values are lost when I click into a new page.

        ...
        <f:facet name="footer">
          <rich:datascroller id="dsViagens" renderIfSinglePage="false" for="tableViagens"/>
        </f:facet>
      </rich:dataTable>
      

       

      4) Another strange problem is that the method getPageDataModel() is called one time at the first time the page is selected, and three times when I clicks "Search" button. Does this occur because it is called one time before change page, after change page and to render dataTable from dataScroller???

       

      Thanks for any helps,