Author: adrianc
Date: Tue Mar 11 17:04:35 2014 New Revision: 1576430 URL: http://svn.apache.org/r1576430 Log: Fixed a bug in Mini-language where numeric constants were localized and converted wrong - https://issues.apache.org/jira/browse/OFBIZ-5281 Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/CompareCondition.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/CompareCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/CompareCondition.java?rev=1576430&r1=1576429&r2=1576430&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/CompareCondition.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/CompareCondition.java Tue Mar 11 17:04:35 2014 @@ -20,6 +20,7 @@ package org.ofbiz.minilang.method.condit import java.util.Collections; import java.util.List; +import java.util.Locale; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.UtilValidate; @@ -113,7 +114,8 @@ public final class CompareCondition exte String value = valueFse.expandString(methodContext.getEnvMap()); String format = formatFse.expandString(methodContext.getEnvMap()); try { - return this.compare.doCompare(fieldVal, value, targetClass, methodContext.getLocale(), methodContext.getTimeZone(), format); + // We use en locale here so constant (literal) values are converted properly. + return this.compare.doCompare(fieldVal, value, targetClass, Locale.ENGLISH, methodContext.getTimeZone(), format); } catch (Exception e) { simpleMethod.addErrorMessage(methodContext, e.getMessage()); } Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java?rev=1576430&r1=1576429&r2=1576430&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java Tue Mar 11 17:04:35 2014 @@ -20,6 +20,7 @@ package org.ofbiz.minilang.method.envops import java.util.HashMap; import java.util.LinkedList; +import java.util.Locale; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; @@ -133,6 +134,7 @@ public final class SetOperation extends @Override public boolean exec(MethodContext methodContext) throws MiniLangException { + boolean isConstant = false; Object newValue = null; if (this.scriptlet != null) { try { @@ -146,10 +148,12 @@ public final class SetOperation extends Debug.logVerbose("In screen getting value for field from [" + this.fromFma.toString() + "]: " + newValue, module); } else if (!this.valueFse.isEmpty()) { newValue = this.valueFse.expand(methodContext.getEnvMap()); + isConstant = true; } // If newValue is still empty, use the default value if (ObjectType.isEmpty(newValue) && !this.defaultFse.isEmpty()) { newValue = this.defaultFse.expand(methodContext.getEnvMap()); + isConstant = true; } if (!setIfNull && newValue == null) { if (Debug.verboseOn()) @@ -176,7 +180,12 @@ public final class SetOperation extends if (targetClass == null) { targetClass = MiniLangUtil.getObjectClassForConversion(newValue); } - newValue = MiniLangUtil.convertType(newValue, targetClass, methodContext.getLocale(), methodContext.getTimeZone(), format); + if (isConstant) { + // We use en locale here so constant (literal) values are converted properly. + newValue = MiniLangUtil.convertType(newValue, targetClass, Locale.ENGLISH, methodContext.getTimeZone(), format); + } else { + newValue = MiniLangUtil.convertType(newValue, targetClass, methodContext.getLocale(), methodContext.getTimeZone(), format); + } } catch (Exception e) { String errMsg = "Could not convert field value for the field: [" + this.fieldFma.toString() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.getMessage(); Debug.logWarning(e, errMsg, module); |
Free forum by Nabble | Edit this page |