Updated model widgets to use operator substitution.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@772709 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrian Crum
2009-05-07 16:58:40 +00:00
parent 0654f711a6
commit f5473d2589
3 changed files with 7 additions and 4 deletions
@@ -500,12 +500,15 @@ public class StringUtil {
*/
public static String convertOperatorSubstitutions(String expression) {
String result = expression;
if (result != null && result.contains("@")) {
if (result != null && (result.contains("@") || result.contains("'"))) {
Set<String> keys = substitionPatternMap.keySet();
for (String replacement : keys) {
Pattern pattern = substitionPatternMap.get(replacement);
result = pattern.matcher(result).replaceAll(replacement);
}
if (Debug.verboseOn()) {
Debug.logVerbose("Converted " + expression + " to " + result, module);
}
}
return result;
}
@@ -1931,7 +1931,7 @@ public class ModelForm extends ModelWidget {
Iterator altTargetIter = this.altTargets.iterator();
while (altTargetIter.hasNext()) {
AltTarget altTarget = (AltTarget) altTargetIter.next();
Object retVal = bsh.eval(altTarget.useWhen);
Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(altTarget.useWhen));
boolean condTrue = false;
// retVal should be a Boolean, if not something weird is up...
if (retVal instanceof Boolean) {
@@ -2607,7 +2607,7 @@ public class ModelForm extends ModelWidget {
// use the same Interpreter (ie with the same context setup) for all evals
Interpreter bsh = this.getBshInterpreter(context);
for (AltRowStyle altRowStyle : this.altRowStyles) {
Object retVal = bsh.eval(altRowStyle.useWhen);
Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(altRowStyle.useWhen));
// retVal should be a Boolean, if not something weird is up...
if (retVal instanceof Boolean) {
Boolean boolVal = (Boolean) retVal;
@@ -2404,7 +2404,7 @@ public class ModelFormField {
context.put("bshInterpreter", bsh);
}
Object retVal = bsh.eval(useWhen);
Object retVal = bsh.eval(StringUtil.convertOperatorSubstitutions(useWhen));
// retVal should be a Boolean, if not something weird is up...
if (retVal instanceof Boolean) {