Author: jleroux
Date: Sat Nov 26 09:02:11 2016
New Revision: 1771440
URL:
http://svn.apache.org/viewvc?rev=1771440&view=revLog:
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/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java
Modified: ofbiz/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java?rev=1771440&r1=1771439&r2=1771440&view=diff==============================================================================
--- ofbiz/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java (original)
+++ ofbiz/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java Sat Nov 26 09:02:11 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());
}
}