Author: jleroux
Date: Fri Jan 12 18:21:38 2018
New Revision: 1821012

URL: http://svn.apache.org/viewvc?rev=1821012&view=rev
Log:
Fixed: pagination errors in "KeywordSearch.ftl" and "ProductSearchSession.java"
(OFBIZ-10154)

To recreate the bug go to
Order->OrderEntry-> Search in the catalog for "g" -> check the amount of shown 
pages and press "Next" -> press "back" -> note how many results you now have

Thanks: Karsten Tymann

Modified:
    
ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/KeywordSearch.ftl
    
ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/TagSearch.ftl
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/KeywordSearch.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/KeywordSearch.ftl?rev=1821012&r1=1821011&r2=1821012&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/KeywordSearch.ftl
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/KeywordSearch.ftl
 Fri Jan 12 18:21:38 2018
@@ -34,31 +34,32 @@ under the License.
 </#if>
 
 <#if productIds?has_content>
-    <div class="product-prevnext">
-        <#-- Start Page Select Drop-Down -->
-        <#assign viewIndexMax = Static["java.lang.Math"].ceil((listSize - 
1)?double / viewSize?double)>
-        <select name="pageSelect" 
onchange="window.location=this[this.selectedIndex].value;">
-          <option value="#">${uiLabelMap.CommonPage} ${viewIndex?int + 1} 
${uiLabelMap.CommonOf} ${viewIndexMax + 1}</option>
-          <#list 0..viewIndexMax as curViewNum>
-            <option 
value="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${curViewNum?int}/~clearSearch=N</@ofbizUrl>">${uiLabelMap.CommonGotoPage}
 ${curViewNum + 1}</option>
-          </#list>
-        </select>
-        <#-- End Page Select Drop-Down -->
-        <b>
-        <#if (viewIndex?int > 0)>
-          <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex?int
 - 1}/~clearSearch=N</@ofbizUrl>" 
class="buttontext">${uiLabelMap.CommonPrevious}</a> |
-        </#if>
-        <#if (listSize?int > 0)>
-          <span>${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} 
${listSize}</span>
-        </#if>
-        <#if highIndex?int < listSize?int>
-          | <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex+1}/~clearSearch=N</@ofbizUrl>"
 class="buttontext">${uiLabelMap.CommonNext}</a>
-        </#if>
-        </b>
-    </div>
-</#if>
+    <#macro paginationControls>
+            <div class="product-prevnext">
+                <#-- Start Page Select Drop-Down -->
+                <#assign viewIndexMax = 
Static["java.lang.Math"].ceil((listSize)?double / viewSize?double)>
+                <select name="pageSelect" 
onchange="window.location=this[this.selectedIndex].value;">
+                  <option value="#">${uiLabelMap.CommonPage} ${viewIndex?int + 
1} ${uiLabelMap.CommonOf} ${viewIndexMax}</option>
+                  <#list 1..viewIndexMax as curViewNum>
+                    <option 
value="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${curViewNum?int
 - 1}/~clearSearch=N</@ofbizUrl>">${uiLabelMap.CommonGotoPage} 
${curViewNum}</option>
+                  </#list>
+                </select>
+                <#-- End Page Select Drop-Down -->
+                <b>
+                <#if (viewIndex?int > 0)>
+                  <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex - 
1}/~clearSearch=N</@ofbizUrl>" 
class="buttontext">${uiLabelMap.CommonPrevious}</a> |
+                </#if>
+                <#if (listSize?int > 0)>
+                  <span>${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} 
${listSize}</span>
+                </#if>
+                <#if highIndex?int < listSize?int>
+                  | <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex+1}/~clearSearch=N</@ofbizUrl>"
 class="buttontext">${uiLabelMap.CommonNext}</a>
+                </#if>
+                </b>
+            </div>
+    </#macro>
 
-<#if productIds?has_content>
+    <@paginationControls/>
     <div class="productsummary-container">
         <#list productIds as productId> <#-- note that there is no boundary 
range because that is being done before the list is put in the content -->
             ${setRequestAttribute("optProductId", productId)}
@@ -66,29 +67,5 @@ under the License.
             ${screens.render(productsummaryScreen)}
         </#list>
     </div>
-</#if>
-
-<#if productIds?has_content>
-    <div class="product-prevnext">
-        <#-- Start Page Select Drop-Down -->
-        <#assign viewIndexMax = Static["java.lang.Math"].ceil((listSize - 
1)?double / viewSize?double)>
-        <select name="pageSelect" 
onchange="window.location=this[this.selectedIndex].value;">
-          <option value="#">${uiLabelMap.CommonPage} ${viewIndex?int + 1} 
${uiLabelMap.CommonOf} ${viewIndexMax + 1}</option>
-          <#list 0..viewIndexMax as curViewNum>
-            <option 
value="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${curViewNum?int}/~clearSearch=N</@ofbizUrl>">${uiLabelMap.CommonGotoPage}
 ${curViewNum + 1}</option>
-          </#list>
-        </select>
-        <#-- End Page Select Drop-Down -->
-        <b>
-        <#if (viewIndex?int > 0)>
-          <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex?int
 - 1}/~clearSearch=N</@ofbizUrl>" 
class="buttontext">${uiLabelMap.CommonPrevious}</a> |
-        </#if>
-        <#if (listSize?int > 0)>
-          <span>${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} 
${listSize}</span>
-        </#if>
-        <#if highIndex?int < listSize?int>
-          | <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex+1}/~clearSearch=N</@ofbizUrl>"
 class="buttontext">${uiLabelMap.CommonNext}</a>
-        </#if>
-        </b>
-    </div>
+    <@paginationControls/>
 </#if>

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/TagSearch.ftl
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/TagSearch.ftl?rev=1821012&r1=1821011&r2=1821012&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/TagSearch.ftl
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/template/entry/catalog/TagSearch.ftl
 Fri Jan 12 18:21:38 2018
@@ -24,31 +24,32 @@ under the License.
 </#if>
 
 <#if productIds?has_content>
-    <div class="product-prevnext">
-        <#-- Start Page Select Drop-Down -->
-        <#assign viewIndexMax = Static["java.lang.Math"].ceil((listSize - 
1)?double / viewSize?double)>
-        <select name="pageSelect" 
onchange="window.location=this[this.selectedIndex].value;">
-          <option value="#">${uiLabelMap.CommonPage} ${viewIndex?int + 1} 
${uiLabelMap.CommonOf} ${viewIndexMax + 1}</option>
-          <#list 0..viewIndexMax as curViewNum>
-            <option 
value="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${curViewNum?int}/~clearSearch=N</@ofbizUrl>">${uiLabelMap.CommonGotoPage}
 ${curViewNum + 1}</option>
-          </#list>
-        </select>
-        <#-- End Page Select Drop-Down -->
-        <b>
-        <#if (viewIndex?int > 0)>
-          <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex?int
 - 1}/~clearSearch=N</@ofbizUrl>" 
class="buttontext">${uiLabelMap.CommonPrevious}</a> |
-        </#if>
-        <#if (listSize?int > 0)>
-          <span>${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} 
${listSize}</span>
-        </#if>
-        <#if highIndex?int < listSize?int>
-          | <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex+1}/~clearSearch=N</@ofbizUrl>"
 class="buttontext">${uiLabelMap.CommonNext}</a>
-        </#if>
-        </b>
-    </div>
-</#if>
+    <#macro paginationControls>
+            <div class="product-prevnext">
+                <#-- Start Page Select Drop-Down -->
+                <#assign viewIndexMax = 
Static["java.lang.Math"].ceil((listSize)?double / viewSize?double)>
+                <select name="pageSelect" 
onchange="window.location=this[this.selectedIndex].value;">
+                  <option value="#">${uiLabelMap.CommonPage} ${viewIndex?int + 
1} ${uiLabelMap.CommonOf} ${viewIndexMax}</option>
+                  <#list 1..viewIndexMax as curViewNum>
+                    <option 
value="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${curViewNum?int
 - 1}/~clearSearch=N</@ofbizUrl>">${uiLabelMap.CommonGotoPage} 
${curViewNum}</option>
+                  </#list>
+                </select>
+                <#-- End Page Select Drop-Down -->
+                <b>
+                <#if (viewIndex?int > 0)>
+                  <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex - 
1}/~clearSearch=N</@ofbizUrl>" 
class="buttontext">${uiLabelMap.CommonPrevious}</a> |
+                </#if>
+                <#if (listSize?int > 0)>
+                  <span>${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} 
${listSize}</span>
+                </#if>
+                <#if highIndex?int < listSize?int>
+                  | <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex+1}/~clearSearch=N</@ofbizUrl>"
 class="buttontext">${uiLabelMap.CommonNext}</a>
+                </#if>
+                </b>
+            </div>
+    </#macro>
 
-<#if productIds?has_content>
+    <@paginationControls/>
     <div class="productsummary-container">
         <#list productIds as productId> <#-- note that there is no boundary 
range because that is being done before the list is put in the content -->
             ${setRequestAttribute("optProductId", productId)}
@@ -56,29 +57,5 @@ under the License.
             ${screens.render(productsummaryScreen)}
         </#list>
     </div>
-</#if>
-
-<#if productIds?has_content>
-    <div class="product-prevnext">
-        <#-- Start Page Select Drop-Down -->
-        <#assign viewIndexMax = Static["java.lang.Math"].ceil((listSize - 
1)?double / viewSize?double)>
-        <select name="pageSelect" 
onchange="window.location=this[this.selectedIndex].value;">
-          <option value="#">${uiLabelMap.CommonPage} ${viewIndex?int + 1} 
${uiLabelMap.CommonOf} ${viewIndexMax + 1}</option>
-          <#list 0..viewIndexMax as curViewNum>
-            <option 
value="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${curViewNum?int}/~clearSearch=N</@ofbizUrl>">${uiLabelMap.CommonGotoPage}
 ${curViewNum + 1}</option>
-          </#list>
-        </select>
-        <#-- End Page Select Drop-Down -->
-        <b>
-        <#if (viewIndex?int > 0)>
-          <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex?int
 - 1}/~clearSearch=N</@ofbizUrl>" 
class="buttontext">${uiLabelMap.CommonPrevious}</a> |
-        </#if>
-        <#if (listSize?int > 0)>
-          <span>${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} 
${listSize}</span>
-        </#if>
-        <#if highIndex?int < listSize?int>
-          | <a 
href="<@ofbizUrl>keywordsearch/~VIEW_SIZE=${viewSize}/~VIEW_INDEX=${viewIndex+1}/~clearSearch=N</@ofbizUrl>"
 class="buttontext">${uiLabelMap.CommonNext}</a>
-        </#if>
-        </b>
-    </div>
+    <@paginationControls/>
 </#if>

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java?rev=1821012&r1=1821011&r2=1821012&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
 Fri Jan 12 18:21:38 2018
@@ -380,7 +380,6 @@ public class ProductSearchSession {
         HttpSession session = request.getSession();
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         Map<String, Object> requestParams = UtilHttp.getParameterMap(request);
-        ProductSearchSession.processSearchParameters(requestParams, request);
 
         // get the current productStoreId
         String productStoreId = ProductStoreWorker.getProductStoreId(request);
@@ -513,11 +512,6 @@ public class ProductSearchSession {
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         Boolean alreadyRun = (Boolean) 
request.getAttribute("processSearchParametersAlreadyRun");
         if (Boolean.TRUE.equals(alreadyRun)) {
-            // even if already run, check the VIEW_SIZE and VIEW_INDEX again, 
just for kicks
-            ProductSearchOptions productSearchOptions = 
getProductSearchOptions(request.getSession());
-            productSearchOptions.setViewIndex((String) 
parameters.get("VIEW_INDEX"));
-            productSearchOptions.setViewSize((String) 
parameters.get("VIEW_SIZE"));
-            productSearchOptions.setPaging((String) parameters.get("PAGING"));
             return;
         }
         request.setAttribute("processSearchParametersAlreadyRun", 
Boolean.TRUE);


Reply via email to