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 2008/12/10 11:39:18 UTC

svn commit: r725053 - in /ofbiz/trunk: applications/order/entitydef/ applications/party/webapp/partymgr/WEB-INF/ applications/party/webapp/partymgr/party/ applications/party/widget/partymgr/ framework/base/src/org/ofbiz/base/util/ framework/widget/src/...

Author: jleroux
Date: Wed Dec 10 02:39:16 2008
New Revision: 725053

URL: http://svn.apache.org/viewvc?rev=725053&view=rev
Log:
A slightly modified patch from Bilgin Ibryam "Allow multi-pagination in a page" (https://issues.apache.org/jira/browse/OFBIZ-1935) - OFBIZ-1935

Modified:
    ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml
    ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
    ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.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/IterateSectionWidget.java

Modified: ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml?rev=725053&r1=725052&r2=725053&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml (original)
+++ ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml Wed Dec 10 02:39:16 2008
@@ -1348,6 +1348,7 @@
       <member-entity entity-alias="SI" entity-name="StatusItem"/>
       <alias-all entity-alias="QWE"/>
       <alias-all entity-alias="WE"/>
+      <!--alias name="statusId" field="statusId" entity-alias="SI"/-->      
       <alias name="statusItemDescription" field="description" entity-alias="SI"/>
       <view-link entity-alias="QWE" rel-entity-alias="WE">
         <key-map field-name="workEffortId"/>
@@ -1361,6 +1362,9 @@
       <relation type="one-nofk" rel-entity-name="Quote">
         <key-map field-name="quoteId"/>
       </relation>
+      <relation type="one-nofk" rel-entity-name="StatusItem">
+        <key-map field-name="statusId"/>
+      </relation>
     </view-entity>
     <view-entity entity-name="RequirementAndRole"
             package-name="org.ofbiz.order.request"

Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml?rev=725053&r1=725052&r2=725053&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml Wed Dec 10 02:39:16 2008
@@ -396,13 +396,13 @@
     <request-map uri="createPartyAttribute">
         <security https="true" auth="true"/>
         <event type="service" path="" invoke="createPartyAttribute"/>
-        <response name="success" type="view" value="EditPartyAttribute"/>
+        <response name="success" type="view" value="viewprofile"/>
         <response name="error" type="view" value="EditPartyAttribute"/>
     </request-map>
     <request-map uri="updatePartyAttribute">
         <security https="true" auth="true"/>
         <event type="service" path="" invoke="updatePartyAttribute"/>
-        <response name="success" type="view" value="EditPartyAttribute"/>
+        <response name="success" type="view" value="viewprofile"/>
         <response name="error" type="view" value="EditPartyAttribute"/>
     </request-map>
     <request-map uri="removePartyAttribute">

Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml?rev=725053&r1=725052&r2=725053&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml Wed Dec 10 02:39:16 2008
@@ -612,7 +612,8 @@
     </form>
     
     <form name="ListCarrierAccounts" type="list" target="updatePartyCarrierAccount"
-        odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
+        odd-row-style="alternate-row" default-table-style="basic-table hover-bar" 
+        paginate="true"  view-size="3" paginate-target="viewprofile" paginate-target-anchor="ListCarrierAccounts">
         <actions>
             <entity-condition entity-name="PartyCarrierAccount" list-name="carrierAccounts" filter-by-date="true">
                 <condition-expr field-name="partyId" env-name="parameters.partyId"></condition-expr>

Modified: ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml?rev=725053&r1=725052&r2=725053&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml (original)
+++ ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml Wed Dec 10 02:39:16 2008
@@ -270,7 +270,7 @@
                                 <label style="h3" text="${uiLabelMap.PageTitleFinancialAccountSummary}"/>
                             </container>
                             <container style="screenlet-body">
-                                <iterate-section entry-name="ownedFinAccount"  paginate="true" paginate-target="viewprofile?partyId=${parameters.partyId}" view-size="3"  list-name="ownedFinAccountList">
+                                <iterate-section entry-name="ownedFinAccount"  paginate="true" paginate-target="viewprofile" view-size="3"  list-name="ownedFinAccountList">
                                     <section>
                                         <actions>
                                             <entity-condition entity-name="FinAccountTrans" list-name="ownedFinAccountTransList">

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=725053&r1=725052&r2=725053&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Wed Dec 10 02:39:16 2008
@@ -919,11 +919,18 @@
     }
 
     public static String stripViewParamsFromQueryString(String queryString) {
+        return stripViewParamsFromQueryString(queryString, null);
+    }
+    
+    public static String stripViewParamsFromQueryString(String queryString, String paginatorNumber) {
         Set<String> paramNames = new HashSet<String>();
-        paramNames.add("VIEW_INDEX");
-        paramNames.add("VIEW_SIZE");
-        paramNames.add("viewIndex");
-        paramNames.add("viewSize");
+        if (UtilValidate.isNotEmpty(paginatorNumber)) {
+            paginatorNumber = "_" + paginatorNumber;
+        }
+        paramNames.add("VIEW_INDEX" + paginatorNumber);
+        paramNames.add("VIEW_SIZE" + paginatorNumber);
+        paramNames.add("viewIndex" + paginatorNumber);
+        paramNames.add("viewSize" + paginatorNumber);
         return stripNamedParamsFromQueryString(queryString, paramNames);
     }
     

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java?rev=725053&r1=725052&r2=725053&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java Wed Dec 10 02:39:16 2008
@@ -112,4 +112,27 @@
         }
         return result;
     }
+
+    public int getPaginatorNumber(Map<String, Object> context) {
+        int paginator_number = 0; 
+        Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));      
+        if (globalCtx != null) {
+            Integer paginateNumberInt= (Integer)globalCtx.get("PAGINATOR_NUMBER");
+            if (paginateNumberInt == null) {    
+                paginateNumberInt = Integer.valueOf(0);
+                globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt);
+            }
+            paginator_number = paginateNumberInt.intValue();
+        }    
+        return paginator_number;
+    }      
+    
+    public void incrementPaginatorNumber(Map<String, Object> context) {    
+        Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
+        if (globalCtx != null) {
+            Integer paginateNumberInt = Integer.valueOf(getPaginatorNumber(context) + 1);
+            globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt);
+        }     
+    }
+    
 }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=725053&r1=725052&r2=725053&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Wed Dec 10 02:39:16 2008
@@ -1306,6 +1306,9 @@
     }
 
     public void preparePager(Map<String, Object> context) {
+        
+        //  increment the paginator
+        this.incrementPaginatorNumber(context);
         this.rowCount = 0;
         String lookupName = this.getListName();
         if (UtilValidate.isEmpty(lookupName)) {
@@ -2185,6 +2188,8 @@
         if (UtilValidate.isEmpty(field)) {
             field = DEFAULT_PAG_INDEX_FIELD;
         }
+        //  append the paginator number
+        field = field + "_" + getPaginatorNumber(context);
         return field;
     }
 
@@ -2199,7 +2204,7 @@
             // try parameters.VIEW_INDEX as that is an old OFBiz convention
             Map parameters = (Map) context.get("parameters");
             if (parameters != null) {
-                value = parameters.get("VIEW_INDEX");
+                value = parameters.get("VIEW_INDEX" + "_" + getPaginatorNumber(context));
                 
                 if (value == null) {
                     value = parameters.get(field);
@@ -2224,6 +2229,8 @@
         if (UtilValidate.isEmpty(field)) {
             field = DEFAULT_PAG_SIZE_FIELD;
         }
+        //  append the paginator number
+        field = field + "_" + getPaginatorNumber(context);
         return field;
     }
 
@@ -2238,7 +2245,7 @@
                 // try parameters.VIEW_SIZE as that is an old OFBiz convention
                 Map parameters = (Map) context.get("parameters");
                 if (parameters != null) {
-                    value = parameters.get("VIEW_SIZE");
+                    value = parameters.get("VIEW_SIZE" + "_" + getPaginatorNumber(context));
 
                     if (value == null) {
                         value = parameters.get(field);

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=725053&r1=725052&r2=725053&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 Wed Dec 10 02:39:16 2008
@@ -2245,6 +2245,7 @@
         }
 
         // get the parametrized pagination index and size fields
+        int paginatorNumber = modelForm.getPaginatorNumber(context);
         String viewIndexParam = modelForm.getPaginateIndexField(context);
         String viewSizeParam = modelForm.getPaginateSizeField(context);
 
@@ -2272,13 +2273,13 @@
         }
 
         // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex"
-        if (viewIndexParam.equals("viewIndex")) viewIndexParam = "VIEW_INDEX";
-        if (viewSizeParam.equals("viewSize")) viewSizeParam = "VIEW_SIZE";
+        if (viewIndexParam.equals("viewIndex" + "_" + paginatorNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber;
+        if (viewSizeParam.equals("viewSize" + "_" + paginatorNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;
 
         String str = (String) context.get("_QBESTRING_");
 
         // strip legacy viewIndex/viewSize params from the query string
-        String queryString = UtilHttp.stripViewParamsFromQueryString(str);
+        String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber);
 
         // strip parametrized index/size params from the query string
         HashSet<String> paramNames = new HashSet<String>();

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=725053&r1=725052&r2=725053&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 Wed Dec 10 02:39:16 2008
@@ -246,6 +246,7 @@
         }
 
         // get the parametrized pagination index and size fields
+        int paginatoNumber = modelForm.getPaginatorNumber(context);
         String viewIndexParam = modelForm.getPaginateIndexField(context);
         String viewSizeParam = modelForm.getPaginateSizeField(context);
 
@@ -271,8 +272,8 @@
         }
 
         // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex"
-        if (viewIndexParam.equals("viewIndex")) viewIndexParam = "VIEW_INDEX";
-        if (viewSizeParam.equals("viewSize")) viewSizeParam = "VIEW_SIZE";
+        if (viewIndexParam.equals("viewIndex" + "_" + paginatoNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatoNumber;
+        if (viewSizeParam.equals("viewSize" + "_" + paginatoNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatoNumber;
 
         ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
         RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
@@ -284,7 +285,7 @@
         }
         String queryString = UtilHttp.urlEncodeArgs(inputFields);
         // strip legacy viewIndex/viewSize params from the query string
-        queryString = UtilHttp.stripViewParamsFromQueryString(queryString);
+        queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatoNumber);
         // strip parametrized index/size params from the query string
         HashSet<String> paramNames = new HashSet<String>();
         paramNames.add(viewIndexParam);

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java?rev=725053&r1=725052&r2=725053&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java Wed Dec 10 02:39:16 2008
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -33,6 +34,8 @@
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilGenerics;
+import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
@@ -114,6 +117,8 @@
             Debug.logError("Object not list or map type", module);
             return;
         }
+        this.incrementPaginatorNumber(context);
+        int startPageNumber = this.getPaginatorNumber(context);
         getListLimits(context, theList);
         int rowCount = 0;
         Iterator iter = theList.iterator();
@@ -140,19 +145,31 @@
                 section.renderWidgetString(writer, contextMs, screenStringRenderer);
             }
         }
+
         if ((itemIndex + 1) < highIndex) {
             setHighIndex(itemIndex + 1);
         }
         setActualPageSize(highIndex - lowIndex);
         if (paginate) {
             try {
+                Integer lastPageNumber = null;
+                Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); 
+                if (globalCtx != null) {
+                    lastPageNumber = (Integer)globalCtx.get("PAGINATOR_NUMBER");
+                    globalCtx.put("PAGINATOR_NUMBER", Integer.valueOf(startPageNumber));
+                }  
+                
                 renderNextPrev(writer, context);   
+
+                if (globalCtx != null) {
+                    globalCtx.put("PAGINATOR_NUMBER", lastPageNumber);
+                }
             } catch(IOException e) {
                 Debug.logError(e, module);   
                 throw new RuntimeException(e.getMessage());
             }
         }
-
+ 
     }
     /*
      * @return
@@ -230,8 +247,10 @@
        if (paginate) {
             try {
                 Map params = (Map)context.get("parameters");
-                String viewIndexString = (String) params.get("VIEW_INDEX");
+                String viewIndexString = (String) params.get("VIEW_INDEX" + "_" + getPaginatorNumber(context));
+                String viewSizeString = (String) params.get("VIEW_SIZE" + "_" + getPaginatorNumber(context));
                 viewIndex = Integer.parseInt(viewIndexString);
+                viewSize = Integer.parseInt(viewSizeString);
             } catch (Exception e) {
                 try {
                     viewIndex = ((Integer) context.get("viewIndex")).intValue();
@@ -240,16 +259,9 @@
                 }
             }
             context.put("viewIndex", Integer.valueOf(this.viewIndex));
-    
-            try {
-                viewSize = ((Integer) context.get("viewSize")).intValue();
-            } catch (Exception e) {
-                //viewSize = DEFAULT_PAGE_SIZE;
-            }
+
             lowIndex = viewIndex * viewSize;
             highIndex = (viewIndex + 1) * viewSize;
-    
-    
         } else {
             viewIndex = 0;
             viewSize = DEFAULT_PAGE_SIZE;
@@ -265,6 +277,19 @@
             targetService = "${targetService}";
         }
         
+        Map<String, Object> inputFields = UtilGenerics.checkMap(context.get("requestParameters"));
+        Map<String, Object> queryStringMap = UtilGenerics.toMap(context.get("queryStringMap"));
+        if (UtilValidate.isNotEmpty(queryStringMap)) {
+            inputFields.putAll(queryStringMap);
+        }
+ 
+        String queryString = UtilHttp.urlEncodeArgs(inputFields);
+        int paginatorNumber = this.getPaginatorNumber(context);
+        queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber);
+       
+        
+       
+        
         if (UtilValidate.isEmpty(targetService)) {
             Debug.logWarning("TargetService is empty.", module);   
             return; 
@@ -331,7 +356,10 @@
             if (linkText.indexOf("?") < 0)  linkText.append("?");
             else linkText.append("&amp;");
             //if (queryString != null && !queryString.equals("null")) linkText += queryString + "&";
-            linkText.append("VIEW_SIZE=").append(viewSize).append("&amp;VIEW_INDEX=").append(viewIndex - 1).append("\"");
+            if (UtilValidate.isNotEmpty(queryString)) {
+                linkText.append(queryString).append("&amp;");
+            }
+            linkText.append("VIEW_SIZE_"+ paginatorNumber + "=").append(viewSize).append("&amp;VIEW_INDEX_" + paginatorNumber + "=").append(viewIndex - 1).append("\"");
 
             // make the link
             writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));           
@@ -349,7 +377,10 @@
             StringBuilder linkText = new StringBuilder(targetService);
             if (linkText.indexOf("?") < 0)  linkText.append("?");
             else linkText.append("&amp;");
-            linkText.append("VIEW_SIZE=").append(viewSize).append("&amp;VIEW_INDEX=").append(viewIndex + 1).append("\"");
+            if (UtilValidate.isNotEmpty(queryString)) {
+                linkText.append(queryString).append("&amp;");
+            }            
+            linkText.append("VIEW_SIZE_" + paginatorNumber + "=").append(viewSize).append("&amp;VIEW_INDEX_" + paginatorNumber + "=").append(viewIndex + 1).append("\"");
 
             // make the link
             writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));



Re: BLOCKER: svn commit: r725053 - in /ofbiz/trunk:applications/order/entitydef/ applications/party/webapp/partymgr/WEB-INF/applications/party/webapp/partymgr/party/applications/party/widget/partymgr/ framework/base/src/org/ofbiz/base/util/framework/widget

Posted by Jacques Le Roux <ja...@les7arts.com>.
Sorry Hans.

I'm looking at this right now. Of course if Bilgin (who wrote the patch) could help that would be great.

Thanks

Jacques

From: "Hans Bakker" <ma...@antwebsystems.com>
> This commit (or later) causes pagination to stop working...
> The page numbers change but the listing does not.....
>
> How to test? set the pagination in
> framework/widget/config/widget.properties to "1"
>
> In the latest svn go to invoice click 'find' and try to paginate....the
> invoiceId shown will not change. (although there are 3)
>
> then go back to r725022, remove the 2 statements containing
> viewindex/viewsize from the findInvoiceScreen in invoicescreens.xml
>
> and see the problem have been solved.....
>
> Bruno or Jaques or somebody else...please have a look, i could not find
> it that quickly....
>
> Regards,
> Hans
>
>
> On Wed, 2008-12-10 at 10:39 +0000, jleroux@apache.org wrote:
>> Author: jleroux
>> Date: Wed Dec 10 02:39:16 2008
>> New Revision: 725053
>>
>> URL: http://svn.apache.org/viewvc?rev=725053&view=rev
>> Log:
>> A slightly modified patch from Bilgin Ibryam "Allow multi-pagination in a page" 
>> (https://issues.apache.org/jira/browse/OFBIZ-1935) - OFBIZ-1935
>>
>> Modified:
>>     ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml
>>     ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
>>     ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
>>     ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml
>>     ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
>>     ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
>>     ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.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/IterateSectionWidget.java
>>
>> Modified: ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml?rev=725053&r1=725052&r2=725053&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml (original)
>> +++ ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml Wed Dec 10 02:39:16 2008
>> @@ -1348,6 +1348,7 @@
>>        <member-entity entity-alias="SI" entity-name="StatusItem"/>
>>        <alias-all entity-alias="QWE"/>
>>        <alias-all entity-alias="WE"/>
>> +      <!--alias name="statusId" field="statusId" entity-alias="SI"/-->
>>        <alias name="statusItemDescription" field="description" entity-alias="SI"/>
>>        <view-link entity-alias="QWE" rel-entity-alias="WE">
>>          <key-map field-name="workEffortId"/>
>> @@ -1361,6 +1362,9 @@
>>        <relation type="one-nofk" rel-entity-name="Quote">
>>          <key-map field-name="quoteId"/>
>>        </relation>
>> +      <relation type="one-nofk" rel-entity-name="StatusItem">
>> +        <key-map field-name="statusId"/>
>> +      </relation>
>>      </view-entity>
>>      <view-entity entity-name="RequirementAndRole"
>>              package-name="org.ofbiz.order.request"
>>
>> Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml?rev=725053&r1=725052&r2=725053&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml (original)
>> +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml Wed Dec 10 02:39:16 2008
>> @@ -396,13 +396,13 @@
>>      <request-map uri="createPartyAttribute">
>>          <security https="true" auth="true"/>
>>          <event type="service" path="" invoke="createPartyAttribute"/>
>> -        <response name="success" type="view" value="EditPartyAttribute"/>
>> +        <response name="success" type="view" value="viewprofile"/>
>>          <response name="error" type="view" value="EditPartyAttribute"/>
>>      </request-map>
>>      <request-map uri="updatePartyAttribute">
>>          <security https="true" auth="true"/>
>>          <event type="service" path="" invoke="updatePartyAttribute"/>
>> -        <response name="success" type="view" value="EditPartyAttribute"/>
>> +        <response name="success" type="view" value="viewprofile"/>
>>          <response name="error" type="view" value="EditPartyAttribute"/>
>>      </request-map>
>>      <request-map uri="removePartyAttribute">
>>
>> Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml?rev=725053&r1=725052&r2=725053&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml (original)
>> +++ ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml Wed Dec 10 02:39:16 2008
>> @@ -612,7 +612,8 @@
>>      </form>
>>
>>      <form name="ListCarrierAccounts" type="list" target="updatePartyCarrierAccount"
>> -        odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
>> +        odd-row-style="alternate-row" default-table-style="basic-table hover-bar"
>> +        paginate="true"  view-size="3" paginate-target="viewprofile" paginate-target-anchor="ListCarrierAccounts">
>>          <actions>
>>              <entity-condition entity-name="PartyCarrierAccount" list-name="carrierAccounts" filter-by-date="true">
>>                  <condition-expr field-name="partyId" env-name="parameters.partyId"></condition-expr>
>>
>> Modified: ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml?rev=725053&r1=725052&r2=725053&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml (original)
>> +++ ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml Wed Dec 10 02:39:16 2008
>> @@ -270,7 +270,7 @@
>>                                  <label style="h3" text="${uiLabelMap.PageTitleFinancialAccountSummary}"/>
>>                              </container>
>>                              <container style="screenlet-body">
>> -                                <iterate-section entry-name="ownedFinAccount"  paginate="true" 
>> paginate-target="viewprofile?partyId=${parameters.partyId}" view-size="3"  list-name="ownedFinAccountList">
>> +                                <iterate-section entry-name="ownedFinAccount"  paginate="true" paginate-target="viewprofile" 
>> view-size="3"  list-name="ownedFinAccountList">
>>                                      <section>
>>                                          <actions>
>>                                              <entity-condition entity-name="FinAccountTrans" 
>> list-name="ownedFinAccountTransList">
>>
>> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=725053&r1=725052&r2=725053&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original)
>> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Wed Dec 10 02:39:16 2008
>> @@ -919,11 +919,18 @@
>>      }
>>
>>      public static String stripViewParamsFromQueryString(String queryString) {
>> +        return stripViewParamsFromQueryString(queryString, null);
>> +    }
>> +
>> +    public static String stripViewParamsFromQueryString(String queryString, String paginatorNumber) {
>>          Set<String> paramNames = new HashSet<String>();
>> -        paramNames.add("VIEW_INDEX");
>> -        paramNames.add("VIEW_SIZE");
>> -        paramNames.add("viewIndex");
>> -        paramNames.add("viewSize");
>> +        if (UtilValidate.isNotEmpty(paginatorNumber)) {
>> +            paginatorNumber = "_" + paginatorNumber;
>> +        }
>> +        paramNames.add("VIEW_INDEX" + paginatorNumber);
>> +        paramNames.add("VIEW_SIZE" + paginatorNumber);
>> +        paramNames.add("viewIndex" + paginatorNumber);
>> +        paramNames.add("viewSize" + paginatorNumber);
>>          return stripNamedParamsFromQueryString(queryString, paramNames);
>>      }
>>
>>
>> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java?rev=725053&r1=725052&r2=725053&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java (original)
>> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java Wed Dec 10 02:39:16 2008
>> @@ -112,4 +112,27 @@
>>          }
>>          return result;
>>      }
>> +
>> +    public int getPaginatorNumber(Map<String, Object> context) {
>> +        int paginator_number = 0;
>> +        Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
>> +        if (globalCtx != null) {
>> +            Integer paginateNumberInt= (Integer)globalCtx.get("PAGINATOR_NUMBER");
>> +            if (paginateNumberInt == null) {
>> +                paginateNumberInt = Integer.valueOf(0);
>> +                globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt);
>> +            }
>> +            paginator_number = paginateNumberInt.intValue();
>> +        }
>> +        return paginator_number;
>> +    }
>> +
>> +    public void incrementPaginatorNumber(Map<String, Object> context) {
>> +        Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
>> +        if (globalCtx != null) {
>> +            Integer paginateNumberInt = Integer.valueOf(getPaginatorNumber(context) + 1);
>> +            globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt);
>> +        }
>> +    }
>> +
>>  }
>>
>> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=725053&r1=725052&r2=725053&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
>> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Wed Dec 10 02:39:16 2008
>> @@ -1306,6 +1306,9 @@
>>      }
>>
>>      public void preparePager(Map<String, Object> context) {
>> +
>> +        //  increment the paginator
>> +        this.incrementPaginatorNumber(context);
>>          this.rowCount = 0;
>>          String lookupName = this.getListName();
>>          if (UtilValidate.isEmpty(lookupName)) {
>> @@ -2185,6 +2188,8 @@
>>          if (UtilValidate.isEmpty(field)) {
>>              field = DEFAULT_PAG_INDEX_FIELD;
>>          }
>> +        //  append the paginator number
>> +        field = field + "_" + getPaginatorNumber(context);
>>          return field;
>>      }
>>
>> @@ -2199,7 +2204,7 @@
>>              // try parameters.VIEW_INDEX as that is an old OFBiz convention
>>              Map parameters = (Map) context.get("parameters");
>>              if (parameters != null) {
>> -                value = parameters.get("VIEW_INDEX");
>> +                value = parameters.get("VIEW_INDEX" + "_" + getPaginatorNumber(context));
>>
>>                  if (value == null) {
>>                      value = parameters.get(field);
>> @@ -2224,6 +2229,8 @@
>>          if (UtilValidate.isEmpty(field)) {
>>              field = DEFAULT_PAG_SIZE_FIELD;
>>          }
>> +        //  append the paginator number
>> +        field = field + "_" + getPaginatorNumber(context);
>>          return field;
>>      }
>>
>> @@ -2238,7 +2245,7 @@
>>                  // try parameters.VIEW_SIZE as that is an old OFBiz convention
>>                  Map parameters = (Map) context.get("parameters");
>>                  if (parameters != null) {
>> -                    value = parameters.get("VIEW_SIZE");
>> +                    value = parameters.get("VIEW_SIZE" + "_" + getPaginatorNumber(context));
>>
>>                      if (value == null) {
>>                          value = parameters.get(field);
>>
>> 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=725053&r1=725052&r2=725053&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 Wed Dec 10 02:39:16 2008
>> @@ -2245,6 +2245,7 @@
>>          }
>>
>>          // get the parametrized pagination index and size fields
>> +        int paginatorNumber = modelForm.getPaginatorNumber(context);
>>          String viewIndexParam = modelForm.getPaginateIndexField(context);
>>          String viewSizeParam = modelForm.getPaginateSizeField(context);
>>
>> @@ -2272,13 +2273,13 @@
>>          }
>>
>>          // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" 
>> and "viewIndex"
>> -        if (viewIndexParam.equals("viewIndex")) viewIndexParam = "VIEW_INDEX";
>> -        if (viewSizeParam.equals("viewSize")) viewSizeParam = "VIEW_SIZE";
>> +        if (viewIndexParam.equals("viewIndex" + "_" + paginatorNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber;
>> +        if (viewSizeParam.equals("viewSize" + "_" + paginatorNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;
>>
>>          String str = (String) context.get("_QBESTRING_");
>>
>>          // strip legacy viewIndex/viewSize params from the query string
>> -        String queryString = UtilHttp.stripViewParamsFromQueryString(str);
>> +        String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber);
>>
>>          // strip parametrized index/size params from the query string
>>          HashSet<String> paramNames = new HashSet<String>();
>>
>> 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=725053&r1=725052&r2=725053&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 Wed Dec 10 02:39:16 2008
>> @@ -246,6 +246,7 @@
>>          }
>>
>>          // get the parametrized pagination index and size fields
>> +        int paginatoNumber = modelForm.getPaginatorNumber(context);
>>          String viewIndexParam = modelForm.getPaginateIndexField(context);
>>          String viewSizeParam = modelForm.getPaginateSizeField(context);
>>
>> @@ -271,8 +272,8 @@
>>          }
>>
>>          // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" 
>> and "viewIndex"
>> -        if (viewIndexParam.equals("viewIndex")) viewIndexParam = "VIEW_INDEX";
>> -        if (viewSizeParam.equals("viewSize")) viewSizeParam = "VIEW_SIZE";
>> +        if (viewIndexParam.equals("viewIndex" + "_" + paginatoNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatoNumber;
>> +        if (viewSizeParam.equals("viewSize" + "_" + paginatoNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatoNumber;
>>
>>          ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
>>          RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
>> @@ -284,7 +285,7 @@
>>          }
>>          String queryString = UtilHttp.urlEncodeArgs(inputFields);
>>          // strip legacy viewIndex/viewSize params from the query string
>> -        queryString = UtilHttp.stripViewParamsFromQueryString(queryString);
>> +        queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatoNumber);
>>          // strip parametrized index/size params from the query string
>>          HashSet<String> paramNames = new HashSet<String>();
>>          paramNames.add(viewIndexParam);
>>
>> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java
>> URL: 
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java?rev=725053&r1=725052&r2=725053&view=diff
>> ==============================================================================
>> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java (original)
>> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java Wed Dec 10 02:39:16 2008
>> @@ -21,6 +21,7 @@
>>  import java.io.IOException;
>>  import java.util.ArrayList;
>>  import java.util.Arrays;
>> +import java.util.HashSet;
>>  import java.util.Iterator;
>>  import java.util.List;
>>  import java.util.Locale;
>> @@ -33,6 +34,8 @@
>>
>>  import org.ofbiz.base.util.Debug;
>>  import org.ofbiz.base.util.GeneralException;
>> +import org.ofbiz.base.util.UtilGenerics;
>> +import org.ofbiz.base.util.UtilHttp;
>>  import org.ofbiz.base.util.UtilMisc;
>>  import org.ofbiz.base.util.UtilProperties;
>>  import org.ofbiz.base.util.UtilValidate;
>> @@ -114,6 +117,8 @@
>>              Debug.logError("Object not list or map type", module);
>>              return;
>>          }
>> +        this.incrementPaginatorNumber(context);
>> +        int startPageNumber = this.getPaginatorNumber(context);
>>          getListLimits(context, theList);
>>          int rowCount = 0;
>>          Iterator iter = theList.iterator();
>> @@ -140,19 +145,31 @@
>>                  section.renderWidgetString(writer, contextMs, screenStringRenderer);
>>              }
>>          }
>> +
>>          if ((itemIndex + 1) < highIndex) {
>>              setHighIndex(itemIndex + 1);
>>          }
>>          setActualPageSize(highIndex - lowIndex);
>>          if (paginate) {
>>              try {
>> +                Integer lastPageNumber = null;
>> +                Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
>> +                if (globalCtx != null) {
>> +                    lastPageNumber = (Integer)globalCtx.get("PAGINATOR_NUMBER");
>> +                    globalCtx.put("PAGINATOR_NUMBER", Integer.valueOf(startPageNumber));
>> +                }
>> +
>>                  renderNextPrev(writer, context);
>> +
>> +                if (globalCtx != null) {
>> +                    globalCtx.put("PAGINATOR_NUMBER", lastPageNumber);
>> +                }
>>              } catch(IOException e) {
>>                  Debug.logError(e, module);
>>                  throw new RuntimeException(e.getMessage());
>>              }
>>          }
>> -
>> +
>>      }
>>      /*
>>       * @return
>> @@ -230,8 +247,10 @@
>>         if (paginate) {
>>              try {
>>                  Map params = (Map)context.get("parameters");
>> -                String viewIndexString = (String) params.get("VIEW_INDEX");
>> +                String viewIndexString = (String) params.get("VIEW_INDEX" + "_" + getPaginatorNumber(context));
>> +                String viewSizeString = (String) params.get("VIEW_SIZE" + "_" + getPaginatorNumber(context));
>>                  viewIndex = Integer.parseInt(viewIndexString);
>> +                viewSize = Integer.parseInt(viewSizeString);
>>              } catch (Exception e) {
>>                  try {
>>                      viewIndex = ((Integer) context.get("viewIndex")).intValue();
>> @@ -240,16 +259,9 @@
>>                  }
>>              }
>>              context.put("viewIndex", Integer.valueOf(this.viewIndex));
>> -
>> -            try {
>> -                viewSize = ((Integer) context.get("viewSize")).intValue();
>> -            } catch (Exception e) {
>> -                //viewSize = DEFAULT_PAGE_SIZE;
>> -            }
>> +
>>              lowIndex = viewIndex * viewSize;
>>              highIndex = (viewIndex + 1) * viewSize;
>> -
>> -
>>          } else {
>>              viewIndex = 0;
>>              viewSize = DEFAULT_PAGE_SIZE;
>> @@ -265,6 +277,19 @@
>>              targetService = "${targetService}";
>>          }
>>
>> +        Map<String, Object> inputFields = UtilGenerics.checkMap(context.get("requestParameters"));
>> +        Map<String, Object> queryStringMap = UtilGenerics.toMap(context.get("queryStringMap"));
>> +        if (UtilValidate.isNotEmpty(queryStringMap)) {
>> +            inputFields.putAll(queryStringMap);
>> +        }
>> +
>> +        String queryString = UtilHttp.urlEncodeArgs(inputFields);
>> +        int paginatorNumber = this.getPaginatorNumber(context);
>> +        queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber);
>> +
>> +
>> +
>> +
>>          if (UtilValidate.isEmpty(targetService)) {
>>              Debug.logWarning("TargetService is empty.", module);
>>              return;
>> @@ -331,7 +356,10 @@
>>              if (linkText.indexOf("?") < 0)  linkText.append("?");
>>              else linkText.append("&amp;");
>>              //if (queryString != null && !queryString.equals("null")) linkText += queryString + "&";
>> -            linkText.append("VIEW_SIZE=").append(viewSize).append("&amp;VIEW_INDEX=").append(viewIndex - 1).append("\"");
>> +            if (UtilValidate.isNotEmpty(queryString)) {
>> +                linkText.append(queryString).append("&amp;");
>> +            }
>> +            linkText.append("VIEW_SIZE_"+ paginatorNumber + "=").append(viewSize).append("&amp;VIEW_INDEX_" + paginatorNumber + 
>> "=").append(viewIndex - 1).append("\"");
>>
>>              // make the link
>>              writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));
>> @@ -349,7 +377,10 @@
>>              StringBuilder linkText = new StringBuilder(targetService);
>>              if (linkText.indexOf("?") < 0)  linkText.append("?");
>>              else linkText.append("&amp;");
>> -            linkText.append("VIEW_SIZE=").append(viewSize).append("&amp;VIEW_INDEX=").append(viewIndex + 1).append("\"");
>> +            if (UtilValidate.isNotEmpty(queryString)) {
>> +                linkText.append(queryString).append("&amp;");
>> +            }
>> +            linkText.append("VIEW_SIZE_" + paginatorNumber + "=").append(viewSize).append("&amp;VIEW_INDEX_" + paginatorNumber + 
>> "=").append(viewIndex + 1).append("\"");
>>
>>              // make the link
>>              writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));
>>
>>
> -- 
> Antwebsystems.com: Quality OFBiz services for competitive prices
> 


BLOCKER: svn commit: r725053 - in /ofbiz/trunk: applications/order/entitydef/ applications/party/webapp/partymgr/WEB-INF/ applications/party/webapp/partymgr/party/ applications/party/widget/partymgr/ framework/base/src/org/ofbiz/base/util/ framework/widget/src/...

Posted by Hans Bakker <ma...@antwebsystems.com>.
This commit (or later) causes pagination to stop working...
The page numbers change but the listing does not.....

How to test? set the pagination in
framework/widget/config/widget.properties to "1"

In the latest svn go to invoice click 'find' and try to paginate....the
invoiceId shown will not change. (although there are 3)

then go back to r725022, remove the 2 statements containing
viewindex/viewsize from the findInvoiceScreen in invoicescreens.xml

and see the problem have been solved.....

Bruno or Jaques or somebody else...please have a look, i could not find
it that quickly....

Regards,
Hans


On Wed, 2008-12-10 at 10:39 +0000, jleroux@apache.org wrote:
> Author: jleroux
> Date: Wed Dec 10 02:39:16 2008
> New Revision: 725053
> 
> URL: http://svn.apache.org/viewvc?rev=725053&view=rev
> Log:
> A slightly modified patch from Bilgin Ibryam "Allow multi-pagination in a page" (https://issues.apache.org/jira/browse/OFBIZ-1935) - OFBIZ-1935
> 
> Modified:
>     ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml
>     ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
>     ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
>     ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml
>     ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
>     ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
>     ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.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/IterateSectionWidget.java
> 
> Modified: ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml?rev=725053&r1=725052&r2=725053&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml (original)
> +++ ofbiz/trunk/applications/order/entitydef/entitymodel_view.xml Wed Dec 10 02:39:16 2008
> @@ -1348,6 +1348,7 @@
>        <member-entity entity-alias="SI" entity-name="StatusItem"/>
>        <alias-all entity-alias="QWE"/>
>        <alias-all entity-alias="WE"/>
> +      <!--alias name="statusId" field="statusId" entity-alias="SI"/-->      
>        <alias name="statusItemDescription" field="description" entity-alias="SI"/>
>        <view-link entity-alias="QWE" rel-entity-alias="WE">
>          <key-map field-name="workEffortId"/>
> @@ -1361,6 +1362,9 @@
>        <relation type="one-nofk" rel-entity-name="Quote">
>          <key-map field-name="quoteId"/>
>        </relation>
> +      <relation type="one-nofk" rel-entity-name="StatusItem">
> +        <key-map field-name="statusId"/>
> +      </relation>
>      </view-entity>
>      <view-entity entity-name="RequirementAndRole"
>              package-name="org.ofbiz.order.request"
> 
> Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml?rev=725053&r1=725052&r2=725053&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml (original)
> +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/controller.xml Wed Dec 10 02:39:16 2008
> @@ -396,13 +396,13 @@
>      <request-map uri="createPartyAttribute">
>          <security https="true" auth="true"/>
>          <event type="service" path="" invoke="createPartyAttribute"/>
> -        <response name="success" type="view" value="EditPartyAttribute"/>
> +        <response name="success" type="view" value="viewprofile"/>
>          <response name="error" type="view" value="EditPartyAttribute"/>
>      </request-map>
>      <request-map uri="updatePartyAttribute">
>          <security https="true" auth="true"/>
>          <event type="service" path="" invoke="updatePartyAttribute"/>
> -        <response name="success" type="view" value="EditPartyAttribute"/>
> +        <response name="success" type="view" value="viewprofile"/>
>          <response name="error" type="view" value="EditPartyAttribute"/>
>      </request-map>
>      <request-map uri="removePartyAttribute">
> 
> Modified: ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml?rev=725053&r1=725052&r2=725053&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml (original)
> +++ ofbiz/trunk/applications/party/webapp/partymgr/party/PartyForms.xml Wed Dec 10 02:39:16 2008
> @@ -612,7 +612,8 @@
>      </form>
>      
>      <form name="ListCarrierAccounts" type="list" target="updatePartyCarrierAccount"
> -        odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
> +        odd-row-style="alternate-row" default-table-style="basic-table hover-bar" 
> +        paginate="true"  view-size="3" paginate-target="viewprofile" paginate-target-anchor="ListCarrierAccounts">
>          <actions>
>              <entity-condition entity-name="PartyCarrierAccount" list-name="carrierAccounts" filter-by-date="true">
>                  <condition-expr field-name="partyId" env-name="parameters.partyId"></condition-expr>
> 
> Modified: ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml?rev=725053&r1=725052&r2=725053&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml (original)
> +++ ofbiz/trunk/applications/party/widget/partymgr/ProfileScreens.xml Wed Dec 10 02:39:16 2008
> @@ -270,7 +270,7 @@
>                                  <label style="h3" text="${uiLabelMap.PageTitleFinancialAccountSummary}"/>
>                              </container>
>                              <container style="screenlet-body">
> -                                <iterate-section entry-name="ownedFinAccount"  paginate="true" paginate-target="viewprofile?partyId=${parameters.partyId}" view-size="3"  list-name="ownedFinAccountList">
> +                                <iterate-section entry-name="ownedFinAccount"  paginate="true" paginate-target="viewprofile" view-size="3"  list-name="ownedFinAccountList">
>                                      <section>
>                                          <actions>
>                                              <entity-condition entity-name="FinAccountTrans" list-name="ownedFinAccountTransList">
> 
> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=725053&r1=725052&r2=725053&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original)
> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Wed Dec 10 02:39:16 2008
> @@ -919,11 +919,18 @@
>      }
>  
>      public static String stripViewParamsFromQueryString(String queryString) {
> +        return stripViewParamsFromQueryString(queryString, null);
> +    }
> +    
> +    public static String stripViewParamsFromQueryString(String queryString, String paginatorNumber) {
>          Set<String> paramNames = new HashSet<String>();
> -        paramNames.add("VIEW_INDEX");
> -        paramNames.add("VIEW_SIZE");
> -        paramNames.add("viewIndex");
> -        paramNames.add("viewSize");
> +        if (UtilValidate.isNotEmpty(paginatorNumber)) {
> +            paginatorNumber = "_" + paginatorNumber;
> +        }
> +        paramNames.add("VIEW_INDEX" + paginatorNumber);
> +        paramNames.add("VIEW_SIZE" + paginatorNumber);
> +        paramNames.add("viewIndex" + paginatorNumber);
> +        paramNames.add("viewSize" + paginatorNumber);
>          return stripNamedParamsFromQueryString(queryString, paramNames);
>      }
>      
> 
> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java?rev=725053&r1=725052&r2=725053&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java (original)
> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java Wed Dec 10 02:39:16 2008
> @@ -112,4 +112,27 @@
>          }
>          return result;
>      }
> +
> +    public int getPaginatorNumber(Map<String, Object> context) {
> +        int paginator_number = 0; 
> +        Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));      
> +        if (globalCtx != null) {
> +            Integer paginateNumberInt= (Integer)globalCtx.get("PAGINATOR_NUMBER");
> +            if (paginateNumberInt == null) {    
> +                paginateNumberInt = Integer.valueOf(0);
> +                globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt);
> +            }
> +            paginator_number = paginateNumberInt.intValue();
> +        }    
> +        return paginator_number;
> +    }      
> +    
> +    public void incrementPaginatorNumber(Map<String, Object> context) {    
> +        Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
> +        if (globalCtx != null) {
> +            Integer paginateNumberInt = Integer.valueOf(getPaginatorNumber(context) + 1);
> +            globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt);
> +        }     
> +    }
> +    
>  }
> 
> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=725053&r1=725052&r2=725053&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Wed Dec 10 02:39:16 2008
> @@ -1306,6 +1306,9 @@
>      }
>  
>      public void preparePager(Map<String, Object> context) {
> +        
> +        //  increment the paginator
> +        this.incrementPaginatorNumber(context);
>          this.rowCount = 0;
>          String lookupName = this.getListName();
>          if (UtilValidate.isEmpty(lookupName)) {
> @@ -2185,6 +2188,8 @@
>          if (UtilValidate.isEmpty(field)) {
>              field = DEFAULT_PAG_INDEX_FIELD;
>          }
> +        //  append the paginator number
> +        field = field + "_" + getPaginatorNumber(context);
>          return field;
>      }
>  
> @@ -2199,7 +2204,7 @@
>              // try parameters.VIEW_INDEX as that is an old OFBiz convention
>              Map parameters = (Map) context.get("parameters");
>              if (parameters != null) {
> -                value = parameters.get("VIEW_INDEX");
> +                value = parameters.get("VIEW_INDEX" + "_" + getPaginatorNumber(context));
>                  
>                  if (value == null) {
>                      value = parameters.get(field);
> @@ -2224,6 +2229,8 @@
>          if (UtilValidate.isEmpty(field)) {
>              field = DEFAULT_PAG_SIZE_FIELD;
>          }
> +        //  append the paginator number
> +        field = field + "_" + getPaginatorNumber(context);
>          return field;
>      }
>  
> @@ -2238,7 +2245,7 @@
>                  // try parameters.VIEW_SIZE as that is an old OFBiz convention
>                  Map parameters = (Map) context.get("parameters");
>                  if (parameters != null) {
> -                    value = parameters.get("VIEW_SIZE");
> +                    value = parameters.get("VIEW_SIZE" + "_" + getPaginatorNumber(context));
>  
>                      if (value == null) {
>                          value = parameters.get(field);
> 
> 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=725053&r1=725052&r2=725053&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 Wed Dec 10 02:39:16 2008
> @@ -2245,6 +2245,7 @@
>          }
>  
>          // get the parametrized pagination index and size fields
> +        int paginatorNumber = modelForm.getPaginatorNumber(context);
>          String viewIndexParam = modelForm.getPaginateIndexField(context);
>          String viewSizeParam = modelForm.getPaginateSizeField(context);
>  
> @@ -2272,13 +2273,13 @@
>          }
>  
>          // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex"
> -        if (viewIndexParam.equals("viewIndex")) viewIndexParam = "VIEW_INDEX";
> -        if (viewSizeParam.equals("viewSize")) viewSizeParam = "VIEW_SIZE";
> +        if (viewIndexParam.equals("viewIndex" + "_" + paginatorNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber;
> +        if (viewSizeParam.equals("viewSize" + "_" + paginatorNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;
>  
>          String str = (String) context.get("_QBESTRING_");
>  
>          // strip legacy viewIndex/viewSize params from the query string
> -        String queryString = UtilHttp.stripViewParamsFromQueryString(str);
> +        String queryString = UtilHttp.stripViewParamsFromQueryString(str, "" + paginatorNumber);
>  
>          // strip parametrized index/size params from the query string
>          HashSet<String> paramNames = new HashSet<String>();
> 
> 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=725053&r1=725052&r2=725053&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 Wed Dec 10 02:39:16 2008
> @@ -246,6 +246,7 @@
>          }
>  
>          // get the parametrized pagination index and size fields
> +        int paginatoNumber = modelForm.getPaginatorNumber(context);
>          String viewIndexParam = modelForm.getPaginateIndexField(context);
>          String viewSizeParam = modelForm.getPaginateSizeField(context);
>  
> @@ -271,8 +272,8 @@
>          }
>  
>          // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex"
> -        if (viewIndexParam.equals("viewIndex")) viewIndexParam = "VIEW_INDEX";
> -        if (viewSizeParam.equals("viewSize")) viewSizeParam = "VIEW_SIZE";
> +        if (viewIndexParam.equals("viewIndex" + "_" + paginatoNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatoNumber;
> +        if (viewSizeParam.equals("viewSize" + "_" + paginatoNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatoNumber;
>  
>          ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
>          RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
> @@ -284,7 +285,7 @@
>          }
>          String queryString = UtilHttp.urlEncodeArgs(inputFields);
>          // strip legacy viewIndex/viewSize params from the query string
> -        queryString = UtilHttp.stripViewParamsFromQueryString(queryString);
> +        queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatoNumber);
>          // strip parametrized index/size params from the query string
>          HashSet<String> paramNames = new HashSet<String>();
>          paramNames.add(viewIndexParam);
> 
> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java?rev=725053&r1=725052&r2=725053&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java (original)
> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java Wed Dec 10 02:39:16 2008
> @@ -21,6 +21,7 @@
>  import java.io.IOException;
>  import java.util.ArrayList;
>  import java.util.Arrays;
> +import java.util.HashSet;
>  import java.util.Iterator;
>  import java.util.List;
>  import java.util.Locale;
> @@ -33,6 +34,8 @@
>  
>  import org.ofbiz.base.util.Debug;
>  import org.ofbiz.base.util.GeneralException;
> +import org.ofbiz.base.util.UtilGenerics;
> +import org.ofbiz.base.util.UtilHttp;
>  import org.ofbiz.base.util.UtilMisc;
>  import org.ofbiz.base.util.UtilProperties;
>  import org.ofbiz.base.util.UtilValidate;
> @@ -114,6 +117,8 @@
>              Debug.logError("Object not list or map type", module);
>              return;
>          }
> +        this.incrementPaginatorNumber(context);
> +        int startPageNumber = this.getPaginatorNumber(context);
>          getListLimits(context, theList);
>          int rowCount = 0;
>          Iterator iter = theList.iterator();
> @@ -140,19 +145,31 @@
>                  section.renderWidgetString(writer, contextMs, screenStringRenderer);
>              }
>          }
> +
>          if ((itemIndex + 1) < highIndex) {
>              setHighIndex(itemIndex + 1);
>          }
>          setActualPageSize(highIndex - lowIndex);
>          if (paginate) {
>              try {
> +                Integer lastPageNumber = null;
> +                Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); 
> +                if (globalCtx != null) {
> +                    lastPageNumber = (Integer)globalCtx.get("PAGINATOR_NUMBER");
> +                    globalCtx.put("PAGINATOR_NUMBER", Integer.valueOf(startPageNumber));
> +                }  
> +                
>                  renderNextPrev(writer, context);   
> +
> +                if (globalCtx != null) {
> +                    globalCtx.put("PAGINATOR_NUMBER", lastPageNumber);
> +                }
>              } catch(IOException e) {
>                  Debug.logError(e, module);   
>                  throw new RuntimeException(e.getMessage());
>              }
>          }
> -
> + 
>      }
>      /*
>       * @return
> @@ -230,8 +247,10 @@
>         if (paginate) {
>              try {
>                  Map params = (Map)context.get("parameters");
> -                String viewIndexString = (String) params.get("VIEW_INDEX");
> +                String viewIndexString = (String) params.get("VIEW_INDEX" + "_" + getPaginatorNumber(context));
> +                String viewSizeString = (String) params.get("VIEW_SIZE" + "_" + getPaginatorNumber(context));
>                  viewIndex = Integer.parseInt(viewIndexString);
> +                viewSize = Integer.parseInt(viewSizeString);
>              } catch (Exception e) {
>                  try {
>                      viewIndex = ((Integer) context.get("viewIndex")).intValue();
> @@ -240,16 +259,9 @@
>                  }
>              }
>              context.put("viewIndex", Integer.valueOf(this.viewIndex));
> -    
> -            try {
> -                viewSize = ((Integer) context.get("viewSize")).intValue();
> -            } catch (Exception e) {
> -                //viewSize = DEFAULT_PAGE_SIZE;
> -            }
> +
>              lowIndex = viewIndex * viewSize;
>              highIndex = (viewIndex + 1) * viewSize;
> -    
> -    
>          } else {
>              viewIndex = 0;
>              viewSize = DEFAULT_PAGE_SIZE;
> @@ -265,6 +277,19 @@
>              targetService = "${targetService}";
>          }
>          
> +        Map<String, Object> inputFields = UtilGenerics.checkMap(context.get("requestParameters"));
> +        Map<String, Object> queryStringMap = UtilGenerics.toMap(context.get("queryStringMap"));
> +        if (UtilValidate.isNotEmpty(queryStringMap)) {
> +            inputFields.putAll(queryStringMap);
> +        }
> + 
> +        String queryString = UtilHttp.urlEncodeArgs(inputFields);
> +        int paginatorNumber = this.getPaginatorNumber(context);
> +        queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber);
> +       
> +        
> +       
> +        
>          if (UtilValidate.isEmpty(targetService)) {
>              Debug.logWarning("TargetService is empty.", module);   
>              return; 
> @@ -331,7 +356,10 @@
>              if (linkText.indexOf("?") < 0)  linkText.append("?");
>              else linkText.append("&amp;");
>              //if (queryString != null && !queryString.equals("null")) linkText += queryString + "&";
> -            linkText.append("VIEW_SIZE=").append(viewSize).append("&amp;VIEW_INDEX=").append(viewIndex - 1).append("\"");
> +            if (UtilValidate.isNotEmpty(queryString)) {
> +                linkText.append(queryString).append("&amp;");
> +            }
> +            linkText.append("VIEW_SIZE_"+ paginatorNumber + "=").append(viewSize).append("&amp;VIEW_INDEX_" + paginatorNumber + "=").append(viewIndex - 1).append("\"");
>  
>              // make the link
>              writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));           
> @@ -349,7 +377,10 @@
>              StringBuilder linkText = new StringBuilder(targetService);
>              if (linkText.indexOf("?") < 0)  linkText.append("?");
>              else linkText.append("&amp;");
> -            linkText.append("VIEW_SIZE=").append(viewSize).append("&amp;VIEW_INDEX=").append(viewIndex + 1).append("\"");
> +            if (UtilValidate.isNotEmpty(queryString)) {
> +                linkText.append(queryString).append("&amp;");
> +            }            
> +            linkText.append("VIEW_SIZE_" + paginatorNumber + "=").append(viewSize).append("&amp;VIEW_INDEX_" + paginatorNumber + "=").append(viewIndex + 1).append("\"");
>  
>              // make the link
>              writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));
> 
> 
-- 
Antwebsystems.com: Quality OFBiz services for competitive prices