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 2014/01/21 21:53:30 UTC
svn commit: r1560176 - in /ofbiz/trunk:
applications/content/webapp/content/WEB-INF/actions/content/
applications/order/webapp/ordermgr/entry/catalog/
applications/party/webapp/partymgr/party/
framework/base/src/org/ofbiz/base/util/ framework/webtools/...
Author: jleroux
Date: Tue Jan 21 20:53:29 2014
New Revision: 1560176
URL: http://svn.apache.org/r1560176
Log:
A patch from Gareth Carter for "last index for paging is not calculated correctly" https://issues.apache.org/jira/browse/OFBIZ-5497
The last index (used on the last button) is not calculated correctly in ftl or the renderer classes. It currently users floor which works only for list sizes that are not multiples of the view size. When you have a list size which is a multiple of the view size, it does not subtract 1 for zero based index and therefore the last button goes to the last page + 1
Examples
listSize = 1
viewSize = 10
listSize / viewSize = 0.1
floor(0.1) = 0
This one produces the correct value
listSize = 20
viewSize = 10
listSize / viewSize = 2
floor(2) = 2
Last index should be 1 because of zero based index but never occurs
To reproduce, enter a view with a list and paging functionality, the list size must be a multiple of the view size
Modified:
ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy
ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl
ofbiz/trunk/applications/party/webapp/partymgr/party/editShoppingList.ftl
ofbiz/trunk/applications/party/webapp/partymgr/party/findparty.ftl
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java
ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
Modified: ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy (original)
+++ ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy Tue Jan 21 20:53:29 2014
@@ -125,7 +125,7 @@ context.highIndex = highIndex;
context.arraySize = arraySize;
context.resultPartialList = resultPartialList;
-viewIndexLast = (int) (arraySize/viewSize);
+viewIndexLast = UtilMisc.getViewLastIndex(arraySize, viewSize);
context.viewIndexLast = viewIndexLast;
contentAssoc = FastList.newInstance();
context.contentAssoc=resultPartialList;
Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl Tue Jan 21 20:53:29 2014
@@ -125,7 +125,7 @@ under the License.
<#assign viewIndexFirst = 0/>
<#assign viewIndexPrevious = viewIndex - 1/>
<#assign viewIndexNext = viewIndex + 1/>
- <#assign viewIndexLast = Static["java.lang.Math"].floor(listSize/viewSize)/>
+ <#assign viewIndexLast = Static["org.ofbiz.base.util.UtilMisc"].getViewLastIndex(listSize, viewSize) />
<#assign messageMap = Static["org.ofbiz.base.util.UtilMisc"].toMap("lowCount", lowIndex, "highCount", highIndex, "total", listSize)/>
<#assign commonDisplaying = Static["org.ofbiz.base.util.UtilProperties"].getMessage("CommonUiLabels", "CommonDisplaying", messageMap, locale)/>
<@nextPrev commonUrl=commonUrl ajaxEnabled=false javaScriptEnabled=false paginateStyle="nav-pager" paginateFirstStyle="nav-first" viewIndex=viewIndex highIndex=highIndex listSize=listSize viewSize=viewSize ajaxFirstUrl="" firstUrl="" paginateFirstLabel="" paginatePreviousStyle="nav-previous" ajaxPreviousUrl="" previousUrl="" paginatePreviousLabel="" pageLabel="" ajaxSelectUrl="" selectUrl="" ajaxSelectSizeUrl="" selectSizeUrl="" commonDisplaying=commonDisplaying paginateNextStyle="nav-next" ajaxNextUrl="" nextUrl="" paginateNextLabel="" paginateLastStyle="nav-last" ajaxLastUrl="" lastUrl="" paginateLastLabel="" paginateViewSizeLabel="" />
Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/editShoppingList.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/editShoppingList.ftl?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/party/editShoppingList.ftl (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/party/editShoppingList.ftl Tue Jan 21 20:53:29 2014
@@ -182,7 +182,7 @@ under the License.
<#assign viewIndexFirst = 0/>
<#assign viewIndexPrevious = viewIndex - 1/>
<#assign viewIndexNext = viewIndex + 1/>
- <#assign viewIndexLast = Static["java.lang.Math"].floor(listSize/viewSize)/>
+ <#assign viewIndexLast = Static["org.ofbiz.base.util.UtilMisc"].getViewLastIndex(listSize, viewSize) />
<#assign messageMap = Static["org.ofbiz.base.util.UtilMisc"].toMap("lowCount", lowIndex, "highCount", highIndex, "total", listSize)/>
<#assign commonDisplaying = Static["org.ofbiz.base.util.UtilProperties"].getMessage("CommonUiLabels", "CommonDisplaying", messageMap, locale)/>
<@nextPrev commonUrl=commonUrl ajaxEnabled=false javaScriptEnabled=false paginateStyle="nav-pager" paginateFirstStyle="nav-first" viewIndex=viewIndex highIndex=highIndex listSize=listSize viewSize=viewSize ajaxFirstUrl="" firstUrl="" paginateFirstLabel="" paginatePreviousStyle="nav-previous" ajaxPreviousUrl="" previousUrl="" paginatePreviousLabel="" pageLabel="" ajaxSelectUrl="" selectUrl="" ajaxSelectSizeUrl="" selectSizeUrl="" commonDisplaying=commonDisplaying paginateNextStyle="nav-next" ajaxNextUrl="" nextUrl="" paginateNextLabel="" paginateLastStyle="nav-last" ajaxLastUrl="" lastUrl="" paginateLastLabel="" paginateViewSizeLabel="" />
Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/findparty.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/findparty.ftl?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/party/findparty.ftl (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/party/findparty.ftl Tue Jan 21 20:53:29 2014
@@ -213,7 +213,7 @@ under the License.
<#assign viewIndexFirst = 0/>
<#assign viewIndexPrevious = viewIndex - 1/>
<#assign viewIndexNext = viewIndex + 1/>
- <#assign viewIndexLast = Static["java.lang.Math"].floor(partyListSize/viewSize)/>
+ <#assign viewIndexLast = Static["org.ofbiz.base.util.UtilMisc"].getViewLastIndex(partyListSize, viewSize) />
<#assign messageMap = Static["org.ofbiz.base.util.UtilMisc"].toMap("lowCount", lowIndex, "highCount", highIndex, "total", partyListSize)/>
<#assign commonDisplaying = Static["org.ofbiz.base.util.UtilProperties"].getMessage("CommonUiLabels", "CommonDisplaying", messageMap, locale)/>
<@nextPrev commonUrl=commonUrl ajaxEnabled=false javaScriptEnabled=false paginateStyle="nav-pager" paginateFirstStyle="nav-first" viewIndex=viewIndex highIndex=highIndex listSize=partyListSize viewSize=viewSize ajaxFirstUrl="" firstUrl="" paginateFirstLabel="" paginatePreviousStyle="nav-previous" ajaxPreviousUrl="" previousUrl="" paginatePreviousLabel="" pageLabel="" ajaxSelectUrl="" selectUrl="" ajaxSelectSizeUrl="" selectSizeUrl="" commonDisplaying=commonDisplaying paginateNextStyle="nav-next" ajaxNextUrl="" nextUrl="" paginateNextLabel="" paginateLastStyle="nav-last" ajaxLastUrl="" lastUrl="" paginateLastLabel="" paginateViewSizeLabel="" />
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilMisc.java Tue Jan 21 20:53:29 2014
@@ -788,4 +788,9 @@ public class UtilMisc {
out.close();
}
}
+
+ public static int getViewLastIndex(int listSize, int viewSize) {
+ return (int)Math.ceil(listSize / viewSize) - 1;
+ }
+
}
Modified: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy (original)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy Tue Jan 21 20:53:29 2014
@@ -209,7 +209,7 @@ context.highIndex = highIndex;
context.arraySize = arraySize;
context.resultPartialList = resultPartialList;
-viewIndexLast = (int) (arraySize/viewSize);
+viewIndexLast = UtilMisc.getViewLastIndex(arraySize, viewSize);
context.viewIndexLast = viewIndexLast;
List fieldList = FastList.newInstance();
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Tue Jan 21 20:53:29 2014
@@ -2303,10 +2303,11 @@ public class MacroFormRenderer implement
}
// Last button
if (highIndex < listSize) {
+ int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize);
if (ajaxEnabled) {
- ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (listSize / viewSize) + anchor, context);
+ ajaxLastUrl = createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + lastIndex + anchor, context);
} else {
- linkText = prepLinkText + (listSize / viewSize) + anchor;
+ linkText = prepLinkText + lastIndex + anchor;
lastUrl = rh.makeLink(this.request, this.response, urlPath + linkText);
}
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Tue Jan 21 20:53:29 2014
@@ -2524,11 +2524,12 @@ public class HtmlFormRenderer extends Ht
// Last button
writer.append(" <li class=\"").append(modelForm.getPaginateLastStyle());
if (highIndex < listSize) {
+ int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize);
writer.append("\"><a href=\"");
if (ajaxEnabled) {
- writer.append("javascript:ajaxUpdateAreas('").append(createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + (listSize / viewSize) + anchor, context)).append("')");
+ writer.append("javascript:ajaxUpdateAreas('").append(createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText + lastIndex + anchor, context)).append("')");
} else {
- linkText = prepLinkText + (listSize / viewSize) + anchor;
+ linkText = prepLinkText + lastIndex + anchor;
appendOfbizUrl(writer, urlPath + linkText);
}
writer.append("\">").append(modelForm.getPaginateLastLabel(context)).append("</a>");
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Tue Jan 21 20:53:29 2014
@@ -340,8 +340,8 @@ public class HtmlScreenRenderer extends
writer.append("<li class=\"").append(modelForm.getPaginateLastStyle());
if (highIndex < listSize) {
writer.append("\"><a href=\"");
- int page = (listSize / viewSize) - 1;
- linkText = prepLinkText + page + anchor;
+ int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize);
+ linkText = prepLinkText + lastIndex + anchor;
// - make the link
writer.append(rh.makeLink(request, response, linkText));
writer.append("\">").append(modelForm.getPaginateLastLabel(context)).append("</a>");
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=1560176&r1=1560175&r2=1560176&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Tue Jan 21 20:53:29 2014
@@ -760,8 +760,8 @@ public class MacroScreenRenderer impleme
// Last button
String lastLinkUrl = "";
if (highIndex < listSize) {
- int page = (listSize / viewSize);
- linkText = prepLinkText + page + anchor;
+ int lastIndex = UtilMisc.getViewLastIndex(listSize, viewSize);
+ linkText = prepLinkText + lastIndex + anchor;
lastLinkUrl = rh.makeLink(request, response, linkText);
}
String nextLinkUrl = "";