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 22:01:19 UTC
svn commit: r1560183 - in /ofbiz/branches/release12.04: ./
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/ ...
Author: jleroux
Date: Tue Jan 21 21:01:19 2014
New Revision: 1560183
URL: http://svn.apache.org/r1560183
Log:
"Applied fix from trunk for revision: 1560176 "
------------------------------------------------------------------------
r1560176 | jleroux | 2014-01-21 21:53:29 +0100 (mar. 21 janv. 2014) | 20 lignes
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/branches/release12.04/ (props changed)
ofbiz/branches/release12.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy
ofbiz/branches/release12.04/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl
ofbiz/branches/release12.04/applications/party/webapp/partymgr/party/editShoppingList.ftl
ofbiz/branches/release12.04/applications/party/webapp/partymgr/party/findparty.ftl
ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java
ofbiz/branches/release12.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy
ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
Propchange: ofbiz/branches/release12.04/
------------------------------------------------------------------------------
Merged /ofbiz/trunk:r1560176
Modified: ofbiz/branches/release12.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy (original)
+++ ofbiz/branches/release12.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy Tue Jan 21 21:01:19 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/branches/release12.04/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl (original)
+++ ofbiz/branches/release12.04/applications/order/webapp/ordermgr/entry/catalog/categorydetail.ftl Tue Jan 21 21:01:19 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/branches/release12.04/applications/party/webapp/partymgr/party/editShoppingList.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/party/webapp/partymgr/party/editShoppingList.ftl?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/party/webapp/partymgr/party/editShoppingList.ftl (original)
+++ ofbiz/branches/release12.04/applications/party/webapp/partymgr/party/editShoppingList.ftl Tue Jan 21 21:01:19 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/branches/release12.04/applications/party/webapp/partymgr/party/findparty.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/party/webapp/partymgr/party/findparty.ftl?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/party/webapp/partymgr/party/findparty.ftl (original)
+++ ofbiz/branches/release12.04/applications/party/webapp/partymgr/party/findparty.ftl Tue Jan 21 21:01:19 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/branches/release12.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java (original)
+++ ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java Tue Jan 21 21:01:19 2014
@@ -1060,4 +1060,9 @@ public class UtilMisc {
out.close();
}
}
+
+ public static int getViewLastIndex(int listSize, int viewSize) {
+ return (int)Math.ceil(listSize / viewSize) - 1;
+ }
+
}
Modified: ofbiz/branches/release12.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy (original)
+++ ofbiz/branches/release12.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy Tue Jan 21 21:01:19 2014
@@ -204,7 +204,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/branches/release12.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Tue Jan 21 21:01:19 2014
@@ -2415,10 +2415,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/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Tue Jan 21 21:01:19 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/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original)
+++ ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Tue Jan 21 21:01:19 2014
@@ -338,8 +338,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/branches/release12.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=1560183&r1=1560182&r2=1560183&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original)
+++ ofbiz/branches/release12.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Tue Jan 21 21:01:19 2014
@@ -759,8 +759,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 = "";