DisplayTag
  1. DisplayTag
  2. DISPL-182

Empty list displayed when start offset == list length

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1
    • Component/s: Paging/Sorting
    • Labels:
      None

      Description

      In the unfortunate event that the starting offset is the same as the number of items in the list, an empty page is shown.
      This error occurs when the page number is saved in the session (using a custom RequestHelper) and the last item on the page is deleted. E.g. there are two pages and the last item on the second page is deleted. The pagenumber is still '2', but all items are shown on the first page, so the result is an empty list.

      The fix is very easy. In the TableTag, the initParameters() method, the invalid page check should be this:
      ----------------------------------------------
      // invalid page requested, go back to page one
      if (start >= fullSize){
         start = 0;
      }
      -----------------------------------------------

      As you can see; when start == fullSize, start has to be changed as well, because there should be at least 1 item on each page. Theoretically this should work as well:
      ----------------------------------------------
      // invalid page requested, go back to the previous page
      while (start >= fullSize){
         start = Math.max( start - this.pagesize, 0 );
      }
      -----------------------------------------------
      Making it go to the previous page, instead of the first in the list.

        Activity

        Hide
        Wannes Simons added a comment -
        Actually the code to go to the previous page is this:
        ----------------------------------------------
        // invalid page requested, go back to the previous page
        while (start >= fullSize){
           start = Math.max( start - this.pagesize, 0 );
           this.pageNumber--;
        }
        -----------------------------------------------
        Show
        Wannes Simons added a comment - Actually the code to go to the previous page is this: ---------------------------------------------- // invalid page requested, go back to the previous page while (start >= fullSize){    start = Math.max( start - this.pagesize, 0 );    this.pageNumber--; } -----------------------------------------------
        Hide
        Wannes Simons added a comment -
        I'm terribly sorry. I should have fully tested, before having commented. The correct code for to go to the previous page is this:
        -----------------------------------------------------
        if ( fullSize > 0 ){
            while (start >= fullSize){
               start = Math.max( start - this.pagesize, 0 );
               this.pageNumber--;
            }
        }
        else{
            start = 0;
            this.pageNumber = 1;
        }
        -----------------------------------------------------
        Show
        Wannes Simons added a comment - I'm terribly sorry. I should have fully tested, before having commented. The correct code for to go to the previous page is this: ----------------------------------------------------- if ( fullSize > 0 ){     while (start >= fullSize){        start = Math.max( start - this.pagesize, 0 );        this.pageNumber--;     } } else{     start = 0;     this.pageNumber = 1; } -----------------------------------------------------
        Hide
        fabrizio giustina added a comment -
        duplicate of DISPL-212 - already fixed for 1.1
        Show
        fabrizio giustina added a comment - duplicate of DISPL-212 - already fixed for 1.1

          People

          • Reporter:
            Wannes Simons
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: