You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/12/11 18:48:38 UTC

svn commit: r1550201 - /ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Author: jleroux
Date: Wed Dec 11 17:48:37 2013
New Revision: 1550201

URL: http://svn.apache.org/r1550201
Log:
A patch from Gareth Carter for "htmlFormMacroLibrary.ftl renderNextPrev does not calculate number of pages correctly" https://issues.apache.org/jira/browse/OFBIZ-5422

There are 2 issues with the existing code.
1 - floor is applied to viewSize only not the computed value
2 - if the listSize divides with viewSize evenly, you'll get one extra
eg
24/2=12 - no of pages = 13
24/5=4.8 - no of pages = 5

Change to correctly calculate the number of pages using ceiling rather than floor

To repoduce this I went into find party screen, search for all and manually set the view size (I had to click next and change the VIEW_SIZE parameter in the url).

In my description I mention 24/2=12 and 24/5=4.8,
24 is number of parties I had
2/5 is the view size

It does not matter what the item size is (as long as its more than 0), you just have to make sure listSize divides by viewSize evenly. In my case 24/2 divided evenly and which should have have given 12 pages but gave 13.


Modified:
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1550201&r1=1550200&r2=1550201&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Wed Dec 11 17:48:37 2013
@@ -743,8 +743,7 @@ Parameter: lastViewName, String, optiona
         <li class="${paginateFirstStyle}<#if viewIndex gt 0>"><a href="<#if ajaxEnabled>javascript:ajaxUpdateAreas('${ajaxFirstUrl}')<#else>${firstUrl}</#if>">${paginateFirstLabel}</a><#else>-disabled"><span>${paginateFirstLabel}</span></#if></li>
         <li class="${paginatePreviousStyle}<#if viewIndex gt 0>"><a href="<#if ajaxEnabled>javascript:ajaxUpdateAreas('${ajaxPreviousUrl}')<#else>${previousUrl}</#if>">${paginatePreviousLabel}</a><#else>-disabled"><span>${paginatePreviousLabel}</span></#if></li>
         <#if listSize gt 0 && javaScriptEnabled><li class="nav-page-select">${pageLabel} <select name="page" size="1" onchange="<#if ajaxEnabled>javascript:ajaxUpdateAreas('${ajaxSelectUrl}')<#else>location.href='${selectUrl}'+this.value;</#if>"><#rt/>
-          <#assign x=listSize/viewSize?floor>
-          <#if listSize gt (viewIndex*viewSize)><#assign x=x+1></#if>
+          <#assign x=(listSize/viewSize)?ceiling>
             <#list 1..x as i>
               <#if i == (viewIndex+1)><option selected="selected" value="<#else><option value="</#if>${i-1}">${i}</option>
             </#list>