2 Replies Latest reply on Jul 10, 2009 7:19 PM by Themis Dakanalis


    Themis Dakanalis Newbie

      Hi, I have implemented a custom data model that extends the SerializableDataModel and uses data pagination in the database. I have also used the dataScroller component for the scrolling.

      When a user requests to see a data page I fetch that page from the database. The problem is that I want to avoid a count query in the database in order to find the total rows. Instead I want to use a default rows number (e.g. 1000) and when a user requests a page greater or equal than the default number to increase the total rows.

      When a user request the last of my default pages (page 100) I manage the request in the walk method of my data model, using the getFirstRow() function, and I increase the number of total rows. The problem is when a user jumps in a page greater than the current total number. In that case the getFirstRow() function doesn't returns the first row of the requested page but the first row of the last valid requested page.

      Any idea about how to implement that scenario?

        • 1. Re: rich:dataScroller
          Ronald van Kuijk Master


          The problem is that I want to avoid a count query in the database in order to find the total rows.
          Why? If you do it once and use some form of caching the result, it is not expensive at all. And liberates you from lots of other possible problems like you describe you have

          • 2. Re: rich:dataScroller
            Themis Dakanalis Newbie

            Hi and thanks for your reply,

            I have measured the execution time of a count query in a table with 2 million of rows stored in a postgresql database and I founded about 4 seconds. I want to avoid, if possible, that delay when the user requests for the first time a data page.

            So, I want to have an approximated count (like google) and to adapt that value when it is needed. I have tried to resolve my problem using a scrollerListener but the method does not called when I jump in a page greater than the (currently calculated) final page.