svn commit: r1771444 - in /ofbiz/branches/release16.11: ./ framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java

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

svn commit: r1771444 - in /ofbiz/branches/release16.11: ./ framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java

jleroux@apache.org
Author: jleroux
Date: Sat Nov 26 09:11:43 2016
New Revision: 1771444

URL: http://svn.apache.org/viewvc?rev=1771444&view=rev
Log:
"Applied fix from trunk for revision: 1771440  "
------------------------------------------------------------------------
r1771440 | jleroux | 2016-11-26 10:02:11 +0100 (sam. 26 nov. 2016) | 9 lignes

Fixed: SimpleMethod: Problem with Variables in key-fields
(OFBIZ-9126)

I found that issue using ContactMechServices for updateContactMech:
The default-message is dynamically set regarding to what contactMechType you are
 using.
The problem was that the variable in property-field was never evaluated as that.

Thanks: Mirko Vogelsmeier
------------------------------------------------------------------------


Modified:
    ofbiz/branches/release16.11/   (props changed)
    ofbiz/branches/release16.11/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java

Propchange: ofbiz/branches/release16.11/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 26 09:11:43 2016
@@ -10,4 +10,4 @@
 /ofbiz/branches/json-integration-refactoring:1634077-1635900
 /ofbiz/branches/multitenant20100310:921280-927264
 /ofbiz/branches/release13.07:1547657
-/ofbiz/trunk:1770481,1770490,1770540
+/ofbiz/trunk:1770481,1770490,1770540,1771440

Modified: ofbiz/branches/release16.11/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java?rev=1771444&r1=1771443&r2=1771444&view=diff
==============================================================================
--- ofbiz/branches/release16.11/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java (original)
+++ ofbiz/branches/release16.11/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java Sat Nov 26 09:11:43 2016
@@ -34,23 +34,33 @@ import org.w3c.dom.Element;
 public final class FlexibleMessage implements Serializable {
 
     private final FlexibleStringExpander messageFse;
-    private final String propertykey;
+    private final FlexibleStringExpander keyFse;
     private final String propertyResource;
+    private String propertykey;
 
     public FlexibleMessage(Element element, String defaultProperty) {
         if (element != null) {
             String message = UtilXml.elementValue(element);
             if (message != null) {
                 messageFse = FlexibleStringExpander.getInstance(message);
+                keyFse = null;
                 propertykey = null;
                 propertyResource = null;
             } else {
                 messageFse = null;
                 propertykey = MiniLangValidate.checkAttribute(element.getAttribute("property"), defaultProperty);
+                int exprStart = propertykey.indexOf(FlexibleStringExpander.openBracket);
+                int exprEnd = propertykey.indexOf(FlexibleStringExpander.closeBracket, exprStart);
+                if (exprStart > -1 && exprStart < exprEnd) {
+                    keyFse = FlexibleStringExpander.getInstance(propertykey);
+                } else {
+                    keyFse = null;
+                }
                 propertyResource = MiniLangValidate.checkAttribute(element.getAttribute("resource"), "DefaultMessagesUiLabels");
             }
         } else {
             messageFse = null;
+            keyFse = null;
             propertykey = defaultProperty;
             propertyResource = "DefaultMessagesUiLabels";
         }
@@ -60,6 +70,9 @@ public final class FlexibleMessage imple
         if (messageFse != null) {
             return messageFse.expandString(methodContext.getEnvMap());
         } else {
+            if (keyFse != null) {
+                propertykey = keyFse.expandString(methodContext.getEnvMap());
+            }
             return UtilProperties.getMessage(propertyResource, propertykey, methodContext.getEnvMap(), methodContext.getLocale());
         }
     }