5 Replies Latest reply on Sep 21, 2017 10:11 AM by Michal Petrov

    How <rich:dataScroller> calculate how many page link ?

    askkuber kuber Newbie

      <rich:dataScroller>

       

      How it calculate page link? What is the logic behind it?

        • 1. Re: How <rich:dataScroller> calculate how many page link ?
          Michal Petrov Master

          I don't understand the question. The scroller knows that table has 60 rows and that it's supposed to display 15 rows at the time so it generates links for 4 pages.

          • 2. Re: How <rich:dataScroller> calculate how many page link ?
            askkuber kuber Newbie

            What if the pagination is server side then how it will calculate because its dynamic ?  I have server side pagination so i changed walk method like this

            public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {

                boolean reload = false;

                if (null != context && context.getCurrentPhaseId().equals(PhaseId.RENDER_RESPONSE)) {

                  reload = true;

                }

                wrappedKeys = new ArrayList<BigInteger>();

             

                SequenceRange sr = (SequenceRange) range;

                int currentRow = sr.getFirstRow();

                rows = sr.getRows();

             

                if (currentRow == 0) {

                  pageNo = 1;

                } else

                  pageNo = (currentRow / rows) + 1;

             

                totalRecord= createSelectWebSeriveQuery(reload);

                MyBean.setDiscrepenciesResultListLoaded(totalRecord);

             

                if (!totalRecord.isEmpty()) {

                  for (SomeObj item : totalRecord) {

                    wrappedKeys.add(item.getId());

                    wrappedData.put(item.getId(), item);

                    // Once data populated to wrappedKeys and wrappedData call the

                    // process method using visitor parameter

                    visitor.process(context, item.getId(), argument);

                  }

                }

              }

            Now issue is that I have 15982 total number of record So total Pages 160

            Total Number of record  = 15982

            rows = 100

            and sr.getFirstRow(); always give FirstRow So this will be like this

            if sr.getFirstRow() = 0 then PageNumber=1;

            if sr.getFirstRow() = 100 then PageNumber=2;

            if sr.getFirstRow() = 200 then PageNumber=3;

            ........................................................

            .......................................................

            .......................................................

            if sr.getFirstRow() = 15700 then PageNumber=158;

            if sr.getFirstRow() = 15800 then PageNumber=159;

            But in last case also sr.getFirstRow() will give 15882(Every time 100 less)

            if sr.getFirstRow() = 15882 then PageNumber=159; (While it should be 160 in this case)

               This creating a issue Can you tell me what is wrong the logic ?

            • 3. Re: How <rich:dataScroller> calculate how many page link ?
              Michal Petrov Master

              As far as I recall if you're fetching records lazily then you need to implement your own datamodel. As for the page number 15882 should return 159 (but I don't get why that would ever be the first row).

              • 4. Re: How <rich:dataScroller> calculate how many page link ?
                askkuber kuber Newbie

                Do you mean logic in walk method is wrong as this method change by me for server side pagination.

                • 5. Re: How <rich:dataScroller> calculate how many page link ?
                  Michal Petrov Master

                  I'm not sure you're referring to. You've said you got 15982 rows (nine hundred) but then you show 15882 (eight hundred) as the number you have an issue with. But no matter what the number is it is the last row, so your getFirstRow() method should never return that number.