2 Replies Latest reply on Jun 14, 2013 5:00 PM by ikos2201

    rich:dataTable and rich:dataScroller. How to ?

    ikos2201

      Hi,

       

      The main idea of this discussion is  very easy!

      We have such poweful components as rich:dataTable and rich:dataScroller . These components provides us with many good features. E.g data table (copied from docs)

       

      But rich:dataTable require a list of some objects to iterate through <rich:dataTable value="#{bean.list}"> and render a part of this data (pagination support).

      If I have 100 000 records in my DB and I wanna to display them with <rich:dataTable> using pagination (e.g. 10 records / page)  I have to retrieve all the records, store them in memory (as a list)

      and only then I will be able to use powerful <rich:dataTable> component. Is there any approches to provide part loading of data (if I need 10 records I will retrieve them from DB, then next 10, ...)

      for rich:dataTable to use it more effectively ? I think in 90% of situations we have such case (not to load all data but provide partial loading). I didn't find out anything about this, I mean how to

      use correct pagination with richfaces components. RichFaces have good demos, a lot of examples, but all these materials are too poor (only .xhtml pages in demos,almost no sources for beans, etc.)

      I think there are another people who has the same problem.

       

      If anybody knows how to solve this problem, write here and maybe we will help a lot of people in the future !

        • 1. Re: rich:dataTable and rich:dataScroller. How to ?
          jhuska

          Hi John,

           

          thank you for your feedback and the effort you have started!

           

          I have created an issue https://issues.jboss.org/browse/RF-13050 for fixing the bean source codes references, which are missing in some demos.

           

          My another suggestion is to take a look at http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=dataTable&sample=arrangeableModel&skin=blueSky

          There is used JPADataModel, which is an abstract implementation of custom ExtendedDataModel. It should help you with the db pagination, sorting and filtering implementation.

           

          The complete source of the showcase can be helpfull as well. You can find it here:

          https://github.com/richfaces4/showcase

           

          What about creating a blog with some information how you will succeed in making the pagination work ? RichFaces opensource community would be thankfull.

          • 2. Re: rich:dataTable and rich:dataScroller. How to ?
            ikos2201

            I think your way is a little bit complicated. So I've found my own solution.

            I have created my own analogue of yours dataScroller (very simple. it looks like << 1 2 3 4 ... >> (each of these numbers are a4j:commandLink) . but I can add any styles if I need). And I'm using this "paging" with yours dataTable. If I have 100 000 records : ) in DB and I want to diplay 15 per page , for example, I get the first 15 records and the list of these values I put in dataTable :

             

            <rich:dataTable id="myTable" value="#{bean.listOfRecords}">....

             

            If I want to get and display the next 15 I click on page two << 1 2 3 .. >> and my action listener that corresponds to the link I've clicked on, retrieve the next portion of data from DB and update listOfRecords (fill in this list with new records) and rerender dataTable : <a4j:commandLink value="2" ... render="myTable" /> I just rerender dataTable with each click on some page.

            1 of 1 people found this helpful