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
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1771440 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java
index b610f94..7e90b77 100644
--- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java
+++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/callops/FlexibleMessage.java
@@ -34,23 +34,33 @@
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 @@
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());
}
}