svn commit: r1564406 - in /ofbiz/branches/release12.04: ./ framework/service/src/org/ofbiz/service/ModelService.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1564406 - in /ofbiz/branches/release12.04: ./ framework/service/src/org/ofbiz/service/ModelService.java

jleroux@apache.org
Author: jleroux
Date: Tue Feb  4 18:14:23 2014
New Revision: 1564406

URL: http://svn.apache.org/r1564406
Log:
"Applied fix from trunk for revision: 1559814"
------------------------------------------------------------------------
r1559814 | jleroux | 2014-01-20 20:38:45 +0100 (lun. 20 janv. 2014) | 38 lignes

A patch from Michael Ende for "SimpleMethod parameters doesnt work with prefix" https://issues.apache.org/jira/browse/OFBIZ-5371

I experienced some problems when a form submitted parameters with prefix directly to a SimpleMethod (through the controller request).
In this case the prefix is not stripped from the parameter name. The patch updates the method ModelService.java:makePrefixMap().

The idea of the prefixMap is:
If you have some fields like packageweight_1(value=55), packageweight_2(value=65) ... in a form and in a service you need a map called packageweight with the following key values

packageweight{1=55;2=56;...}

The Problem is that the function makePrefixMap doesn't replace the Prefix.

For Example:
On the "Complete" button of the Facility->Shipment screen we call an event and not the completePack service directly.
The event checks some user rights and after that he call the completePack service. If we call the service from an event there throws an NumberFormatException because the packeweight-PrefixMap contains the prefixes.

This is my event description:
 <simple-method method-name="completePackCheckPermission"
        short-description="Check if this user has permission to create a picklist role"
        login-required="true">
        <check-permission permission="LOGISTICS_CREATE">
            <alt-permission permission="LOGISTICS_ADMIN"/>
            <fail-property resource="EcommerceLogisticsErrorUiLabels" property="NoPermissionForUsage" />
        </check-permission>
        <check-errors />

        <session-to-field field="packingSession"/>
        <set field="parameters.packingSession" from-field="packingSession"/>

        <set-service-fields service-name="completePack" to-map="serviceParameters"
            map="parameters" />
        <call-service service-name="completePack" in-map-name="serviceParameters" />
        <return />
    </simple-method>

jleroux: I'm not quite sure there are no side-effects, but I was not able to find one. So I will wait some time before backporting...


------------------------------------------------------------------------


Modified:
    ofbiz/branches/release12.04/   (props changed)
    ofbiz/branches/release12.04/framework/service/src/org/ofbiz/service/ModelService.java

Propchange: ofbiz/branches/release12.04/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1559814

Modified: ofbiz/branches/release12.04/framework/service/src/org/ofbiz/service/ModelService.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/service/src/org/ofbiz/service/ModelService.java?rev=1564406&r1=1564405&r2=1564406&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/service/src/org/ofbiz/service/ModelService.java (original)
+++ ofbiz/branches/release12.04/framework/service/src/org/ofbiz/service/ModelService.java Tue Feb  4 18:14:23 2014
@@ -919,6 +919,7 @@ public class ModelService extends Abstra
         for (Map.Entry<String, ? extends Object> entry: source.entrySet()) {
             String key = entry.getKey();
             if (key.startsWith(param.stringMapPrefix)) {
+                key=key.replace(param.stringMapPrefix,"");
                 paramMap.put(key, entry.getValue());
             }
         }