You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2009/01/29 15:50:45 UTC
svn commit: r738870 - in /ofbiz/trunk/framework:
base/src/org/ofbiz/base/util/string/UelUtil.java
widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
Author: jleroux
Date: Thu Jan 29 14:50:45 2009
New Revision: 738870
URL: http://svn.apache.org/viewvc?rev=738870&view=rev
Log:
A slightly modified patch from Karim Rahimpur "Localized values are not retrieved from LocalizedMaps (through BasicVariableMapper)" '(https://issues.apache.org/jira/browse/OFBIZ-2148) - OFBIZ-2148
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java?rev=738870&r1=738869&r2=738870&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelUtil.java Thu Jan 29 14:50:45 2009
@@ -125,8 +125,26 @@
this.variables = UtilGenerics.cast(context);
this.elContext = parentContext;
}
+
+ /**
+ * Returns a BasicValueExpression containing the value of the named variable.
+ * Resolves against LocalizedMap if available.
+ * @param variable the variable's name
+ * @return a BasicValueExpression containing the variable's value or null if the variable is unknown
+ */
public ValueExpression resolveVariable(String variable) {
- Object obj = this.variables.get(variable);
+ Object obj = null;
+ //Object obj = this.variables.get(variable);
+ if (this.variables instanceof LocalizedMap) {
+ Locale locale = UtilMisc.ensureLocale(this.variables.get("locale"));
+ Object localizedObj = ((LocalizedMap) this.variables).get(variable, locale);
+ if (localizedObj == null) {
+ localizedObj = this.variables.get(variable);
+ }
+ obj = localizedObj;
+ } else {
+ obj = this.variables.get(variable);
+ }
if (obj != null) {
return new BasicValueExpression(obj);
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=738870&r1=738869&r2=738870&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Thu Jan 29 14:50:45 2009
@@ -719,6 +719,16 @@
String action = modelFormField.getAction(context);
String currentValue = modelFormField.getEntry(context);
+ // Get the current value's description from the option value. If there
+ // is a localized version it will be there.
+ String currentDescription = null;
+ if (UtilValidate.isNotEmpty(currentValue)) {
+ for (ModelFormField.OptionValue optionValue : allOptionValues) {
+ if (optionValue.getKey().equals(currentValue)) {
+ currentDescription = optionValue.getDescription();
+ }
+ }
+ }
if (ajaxEnabled) {
writer.append("<input type=\"text\"");
@@ -746,7 +756,7 @@
if (UtilValidate.isNotEmpty(currentValue)) {
writer.append(" value=\"");
- String explicitDescription = dropDownField.getCurrentDescription(context);
+ String explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context));
if (UtilValidate.isNotEmpty(explicitDescription)) {
writer.append(explicitDescription);
} else {
@@ -841,7 +851,7 @@
writer.append(" value=\"");
writer.append(currentValue);
writer.append("\">");
- String explicitDescription = dropDownField.getCurrentDescription(context);
+ String explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context));
if (UtilValidate.isNotEmpty(explicitDescription)) {
writer.append(explicitDescription);
} else {