Author: jleroux
Date: Tue Jan 21 21:01:27 2014 New Revision: 1560184 URL: http://svn.apache.org/r1560184 Log: "Applied fix from trunk for revision: 1560176 " (Only partly some files were not yet concerned) ------------------------------------------------------------------------ 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/release11.04/ (props changed) ofbiz/branches/release11.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java ofbiz/branches/release11.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Propchange: ofbiz/branches/release11.04/ ------------------------------------------------------------------------------ Merged /ofbiz/trunk:r1560176 Modified: ofbiz/branches/release11.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy?rev=1560184&r1=1560183&r2=1560184&view=diff ============================================================================== --- ofbiz/branches/release11.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy (original) +++ ofbiz/branches/release11.04/applications/content/webapp/content/WEB-INF/actions/content/GetContentLookupList.groovy Tue Jan 21 21:01:27 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/release11.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java?rev=1560184&r1=1560183&r2=1560184&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java (original) +++ ofbiz/branches/release11.04/framework/base/src/org/ofbiz/base/util/UtilMisc.java Tue Jan 21 21:01:27 2014 @@ -1058,4 +1058,9 @@ public class UtilMisc { out.close(); } } + + public static int getViewLastIndex(int listSize, int viewSize) { + return (int)Math.ceil(listSize / viewSize) - 1; + } + } Modified: ofbiz/branches/release11.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy?rev=1560184&r1=1560183&r2=1560184&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy (original) +++ ofbiz/branches/release11.04/framework/webtools/webapp/webtools/WEB-INF/actions/entity/FindGeneric.groovy Tue Jan 21 21:01:27 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/release11.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1560184&r1=1560183&r2=1560184&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Tue Jan 21 21:01:27 2014 @@ -2397,10 +2397,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/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=1560184&r1=1560183&r2=1560184&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original) +++ ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Tue Jan 21 21:01:27 2014 @@ -2500,11 +2500,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/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=1560184&r1=1560183&r2=1560184&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original) +++ ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Tue Jan 21 21:01:27 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/release11.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=1560184&r1=1560183&r2=1560184&view=diff ============================================================================== --- ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original) +++ ofbiz/branches/release11.04/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Tue Jan 21 21:01:27 2014 @@ -761,8 +761,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 = ""; |
Free forum by Nabble | Edit this page |