[ 
http://jira.magnolia-cms.com/browse/MGNLSTK-677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bert Leunis updated MGNLSTK-677:
--------------------------------

    Attachment: STKPager.java.patch

Voilà, a small patch. When the offset of the requested page is beyond the 
actual number of items, the offset is set to that of the last page of items. 
Also added some code to prevent unfortunate DivideByZero errors.

> Exception in STKPager::getPageItem()
> ------------------------------------
>
>                 Key: MGNLSTK-677
>                 URL: http://jira.magnolia-cms.com/browse/MGNLSTK-677
>             Project: Magnolia Standard Templating Kit
>          Issue Type: Bug
>          Components: paragraphs
>    Affects Versions: 1.3.4
>            Reporter: Stefan Baur
>            Assignee: Ondřej Chytil
>            Priority: Trivial
>             Fix For: 1.3.x
>
>         Attachments: STKPager.java.patch
>
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> the following line
>     subList = ((List)items).subList(offset, limit);
> generates an exception 
>     java.lang.IllegalArgumentException: fromIndex(4) > toIndex(2)
> if offset is larger than limit. 
> FIX:
> ----
>     public Collection getPageItems() {
>         Collection subList = items;
>         int offset = getOffset();
>         if(count > 0) {
>             int limit = maxResultsPerPage + offset;
>             if(items.size() < limit) {
>                 limit = count;
>             }
>             if(offset < limit){
>               subList = ((List)items).subList(offset, limit);
>             }else{
>               subList = items;
>             }
>         }
>         return subList;
>     }
> This error happens if the GET Parameter currentPage is set (for example from 
> an old session or an old link), but there are not enought items in the 
> current Collection.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to