[MGNLSTK-744] Paging broken due to wrong offset calculation Created: 11/Feb/11  Updated: 09/Aug/12  Resolved: 17/Feb/11

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: None
Affects Version/s: 1.4.2
Fix Version/s: 1.4.3

Type: Bug Priority: Major
Reporter: Frank Rittinger Assignee: Ondrej Chytil
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

all systems


Issue Links:
causality
caused by MGNLSTK-677 Exception in STKPager::getPageItem() Closed
is causing MGNLSTK-988 STKPager calculates wrong -> newsOver... Closed
duplicate
is duplicated by MGNLSTK-749 STKPager: getOffset() Closed
relation
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Date of First Response:

 Description   

STKPager calculates wrong sublist for display due to an error in the offset calculation. This was introduced by the update from 1.4.1 to 1.4.2:

    protected int getOffset() {
        int offset = ((getCurrentPage()) * maxResultsPerPage) -1;
        if(offset > count) {
            int pages = count / maxResultsPerPage;
            offset = pages * maxResultsPerPage;
        }
        return offset;
    }

should be

    protected int getOffset() {
        int offset = (getCurrentPage() - 1) * maxResultsPerPage;
        if(offset > count) {
            int pages = count / maxResultsPerPage;
            offset = pages * maxResultsPerPage;
        }
        return offset;
    }


 Comments   
Comment by Magnolia International [ 11/Feb/11 ]

Thanks for the report and patch, Frank !
Ondrej, can you make sure this gets covered by tests ?

Comment by Ondrej Chytil [ 11/Feb/11 ]

Yes, actually it's necessary because I was not able to reproduce it on demo-project.
And I'm sure the original patch from MGNLSTK-677 was causing similar issue. That was the reason to modify it.

Generated at Mon Feb 12 07:30:00 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.