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 2013/10/19 15:16:55 UTC
svn commit: r1533755 - in /ofbiz/branches/release13.07: ./
applications/party/webapp/partymgr/WEB-INF/actions/party/
applications/party/webapp/partymgr/party/
specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/
specialpurpose/ecomme...
Author: jleroux
Date: Sat Oct 19 13:16:54 2013
New Revision: 1533755
URL: http://svn.apache.org/r1533755
Log:
"Applied fix from trunk for revision: 1532342"
------------------------------------------------------------------------
r1532342 | jleroux | 2013-10-15 16:03:54 +0200 (mar. 15 oct. 2013) | 11 lignes
This fixes
"Addition of item to shopping list is not working" https://issues.apache.org/jira/browse/OFBIZ-4903
"Problem when saving a product to a shopping list" https://issues.apache.org/jira/browse/OFBIZ-4589
I don't pretend it's glorious code. For instance I gave up on trying to have the groovy changes snippets consistent in both components and to reuse the way it's done in party. And the way I secured the indexes remember me when I was hacking in APL. For my defense, it was really a mess... and my time is limited...
Anyway, at least it fixes all the issues I crossed in shopping list editing in both party and ecommerce components:
* NPE on sessions ending
* wrong and failing (NPE in ftl) pagination
* error on pagination links after adding a product
Tested with both 2 and 20 size view on both sides
------------------------------------------------------------------------
Modified:
ofbiz/branches/release13.07/ (props changed)
ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/EditShoppingList.groovy
ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editShoppingList.ftl
ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/EditShoppingList.groovy
ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/shoppinglist/editShoppingList.ftl
Propchange: ofbiz/branches/release13.07/
------------------------------------------------------------------------------
Merged /ofbiz/trunk:r1532342
Modified: ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/EditShoppingList.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/EditShoppingList.groovy?rev=1533755&r1=1533754&r2=1533755&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/EditShoppingList.groovy (original)
+++ ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/EditShoppingList.groovy Sat Oct 19 13:16:54 2013
@@ -20,7 +20,9 @@
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.product.catalog.CatalogWorker;
-import org.ofbiz.webapp.website.WebSiteWorker
+import org.ofbiz.webapp.website.WebSiteWorker;
+import org.ofbiz.base.util.UtilProperties ;
+
prodCatalogId = CatalogWorker.getCurrentCatalogId(request);
webSiteId = WebSiteWorker.getWebSiteId(request);
@@ -104,16 +106,13 @@ if (shoppingListId) {
// pagination for the shopping list
viewIndex = Integer.valueOf(parameters.VIEW_INDEX ?: 0);
viewSize = Integer.valueOf(parameters.VIEW_SIZE ?: 20);
- listSize = 0;
- if (shoppingListItemDatas)
- listSize = shoppingListItemDatas.size();
+ listSize = shoppingListItemDatas ? shoppingListItemDatas.size() : 0;
- lowIndex = viewIndex * viewSize;
+ lowIndex = (viewIndex * viewSize) + 1;
highIndex = (viewIndex + 1) * viewSize;
+ highIndex = highIndex > listSize ? listSize : highIndex;
+ lowIndex = lowIndex > highIndex ? highIndex : lowIndex;
- if (highIndex > listSize) {
- highIndex = listSize;
- }
context.viewIndex = viewIndex;
context.viewSize = viewSize;
context.listSize = listSize;
Modified: ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editShoppingList.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editShoppingList.ftl?rev=1533755&r1=1533754&r2=1533755&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editShoppingList.ftl (original)
+++ ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editShoppingList.ftl Sat Oct 19 13:16:54 2013
@@ -196,7 +196,7 @@ under the License.
<td> </td>
</tr>
<#assign alt_row = false>
- <#list shoppingListItemDatas[lowIndex..highIndex-1] as shoppingListItemData>
+ <#list shoppingListItemDatas[lowIndex-1..highIndex-1] as shoppingListItemData>
<#assign shoppingListItem = shoppingListItemData.shoppingListItem>
<#assign product = shoppingListItemData.product>
<#assign productContentWrapper = Static["org.ofbiz.product.product.ProductContentWrapper"].makeProductContentWrapper(product, request)>
@@ -251,7 +251,7 @@ under the License.
<br class="clear"/>
</div>
<div class="screenlet-body">
- <form name="addToShoppingList" method="post" action="<@ofbizUrl>addItemToShoppingList<#if requestAttributes._CURRENT_VIEW_?exists>/${requestAttributes._CURRENT_VIEW_}</#...@ofbizUrl>">
+ <form name="addToShoppingList" method="post" action="<@o...@ofbizUrl>">
<input type="hidden" name="shoppingListId" value="${shoppingList.shoppingListId}" />
<input type="hidden" name="partyId" value="${shoppingList.partyId?if_exists}" />
<input type="text" name="productId" value="" />
Modified: ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/EditShoppingList.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/EditShoppingList.groovy?rev=1533755&r1=1533754&r2=1533755&view=diff
==============================================================================
--- ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/EditShoppingList.groovy (original)
+++ ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/EditShoppingList.groovy Sat Oct 19 13:16:54 2013
@@ -31,7 +31,13 @@ import org.ofbiz.product.store.*;
import org.ofbiz.service.calendar.*;
import org.ofbiz.webapp.website.WebSiteWorker;
-party = userLogin.getRelatedOne("Party", false);
+if (userLogin)
+{
+ party = userLogin.getRelatedOne("Party", false);
+} else {
+ return; // session ended, prevents a NPE
+}
+
cart = ShoppingCartEvents.getCartObject(request);
currencyUomId = cart.getCurrency();
@@ -140,15 +146,13 @@ if (shoppingListId) {
// pagination for the shopping list
viewIndex = Integer.valueOf(parameters.VIEW_INDEX ?: 1);
viewSize = Integer.valueOf(parameters.VIEW_SIZE ?: 20);
- listSize = 0;
- if (shoppingListItemDatas)
- listSize = shoppingListItemDatas.size();
-
- lowIndex = (((viewIndex - 1) * viewSize) + 1);
+ listSize = shoppingListItemDatas ? shoppingListItemDatas.size() : 0;
+
+ lowIndex = ((viewIndex - 1) * viewSize) + 1;
highIndex = viewIndex * viewSize;
- if (highIndex > listSize) {
- highIndex = listSize;
- }
+ highIndex = highIndex > listSize ? listSize : highIndex;
+ lowIndex = lowIndex > highIndex ? highIndex : lowIndex;
+
context.viewIndex = viewIndex;
context.viewSize = viewSize;
context.listSize = listSize;
Modified: ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/shoppinglist/editShoppingList.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/shoppinglist/editShoppingList.ftl?rev=1533755&r1=1533754&r2=1533755&view=diff
==============================================================================
--- ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/shoppinglist/editShoppingList.ftl (original)
+++ ofbiz/branches/release13.07/specialpurpose/ecommerce/webapp/ecommerce/shoppinglist/editShoppingList.ftl Sat Oct 19 13:16:54 2013
@@ -54,17 +54,20 @@ under the License.
</script>
<br />
<#macro paginationControls>
- <#assign viewIndexMax = Static["java.lang.Math"].ceil((listSize - 1)?double / viewSize?double)>
- <#if (viewIndexMax?int > 0)>
+ <#assign viewIndexMax = Static["java.lang.Math"].ceil((listSize)?double / viewSize?double)>
+ <#if (viewIndexMax?int >= 1)>
<div class="product-prevnext">
<#-- Start Page Select Drop-Down -->
<select name="pageSelect" onchange="callDocumentByPaginate(this[this.selectedIndex].value);">
- <option value="#">${uiLabelMap.CommonPage} ${viewIndex?int} ${uiLabelMap.CommonOf} ${viewIndexMax + 1}</option>
- <#list 0..viewIndexMax as curViewNum>
- <option value="${shoppingListId?if_exists}~${viewSize}~${curViewNum?int + 1}">${uiLabelMap.CommonGotoPage} ${curViewNum + 1}</option>
- </#list>
+ <option value="#">${uiLabelMap.CommonPage} ${viewIndex?int} ${uiLabelMap.CommonOf} ${viewIndexMax}</option>
+ <#if (viewIndex?int > 1)>
+ <#list 0..viewIndexMax as curViewNum>
+ <option value="${shoppingListId?if_exists}~${viewSize}~${curViewNum?int + 1}">${uiLabelMap.CommonGotoPage} ${curViewNum + 1}</option>
+ </#list>
+ </#if>
</select>
<#-- End Page Select Drop-Down -->
+
<#if (viewIndex?int > 1)>
<a href="javascript: void(0);" onclick="callDocumentByPaginate('${shoppingListId?if_exists}~${viewSize}~${viewIndex?int - 1}');" class="buttontext">${uiLabelMap.CommonPrevious}</a> |
</#if>
@@ -586,7 +589,7 @@ under the License.
<div class="h3">${uiLabelMap.CommonQuickAddList}</div>
</div>
<div class="screenlet-body">
- <form name="addToShoppingList" method="post" action="<@ofbizUrl>addItemToShoppingList<#if requestAttributes._CURRENT_VIEW_?exists>/${requestAttributes._CURRENT_VIEW_}</#...@ofbizUrl>">
+ <form name="addToShoppingList" method="post" action="<@o...@ofbizUrl>">
<input type="hidden" name="shoppingListId" value="${shoppingList.shoppingListId}"/>
<input type="text" class="inputBox" name="productId" value="${requestParameters.add_product_id?if_exists}"/>
<#if reservStart?exists></td><td>${uiLabelMap.EcommerceStartDate}</td><td><input type="text" class="inputBox" size="10" name="reservStart" value="${requestParameters.reservStart?default("")}" /></td><td> ${uiLabelMap.EcommerceLength}:</td><td><input type="text" class="inputBox" size="2" name="reservLength" value="${requestParameters.reservLength?default("")}" /></td></tr><tr><td> </td><td> </td><td>${uiLabelMap.OrderNbrPersons}:</td><td><input type="text" class="inputBox" size="3" name="reservPersons" value="${requestParameters.reservPersons?default("1")}" /></td><td nowrap="nowrap"></#if> ${uiLabelMap.CommonQuantity} :</td><td><input type="text" class="inputBox" size="5" name="quantity" value="${requestParameters.quantity?default("1")}" /></td><td>