svn commit: r1554682 - in /ofbiz/branches/release13.07: ./ applications/party/script/org/ofbiz/party/party/ applications/party/webapp/partymgr/WEB-INF/actions/party/ applications/party/webapp/partymgr/party/ framework/minilang/dtd/ framework/minilang/s...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1554682 - in /ofbiz/branches/release13.07: ./ applications/party/script/org/ofbiz/party/party/ applications/party/webapp/partymgr/WEB-INF/actions/party/ applications/party/webapp/partymgr/party/ framework/minilang/dtd/ framework/minilang/s...

jleroux@apache.org
Author: jleroux
Date: Wed Jan  1 21:31:41 2014
New Revision: 1554682

URL: http://svn.apache.org/r1554682
Log:
"Applied fix from trunk for revision: 1554681  "
------------------------------------------------------------------------
r1554681 | jleroux | 2014-01-01 22:30:12 +0100 (mer. 01 janv. 2014) | 5 lignes

This closes "Set field in (at least) widget screen does not take into account a locale for (at least) the Float type" https://issues.apache.org/jira/browse/OFBIZ-5453
And definitively fixes issues with i18n of geolocation

It introduces a "locale" attribute to the "set" operation in widget (I only tested screen, form is quite similar, should be ok) and minilang.

------------------------------------------------------------------------


Modified:
    ofbiz/branches/release13.07/   (props changed)
    ofbiz/branches/release13.07/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml
    ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy
    ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editGeoLocation.ftl
    ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd
    ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java
    ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
    ofbiz/branches/release13.07/framework/widget/dtd/widget-form.xsd
    ofbiz/branches/release13.07/framework/widget/dtd/widget-screen.xsd
    ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java
    ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java

Propchange: ofbiz/branches/release13.07/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1554681

Modified: ofbiz/branches/release13.07/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml (original)
+++ ofbiz/branches/release13.07/applications/party/script/org/ofbiz/party/party/PartySimpleEvents.xml Wed Jan  1 21:31:41 2014
@@ -128,8 +128,8 @@ under the License.
     <simple-method method-name="editGeoLocation" short-description="Edit GeoLocation">
         <if-empty field="parameters.geoPointId">
             <set field="createGeoPointMap.dataSourceId" value="GEOPT_GOOGLE"/>
-            <set field="createGeoPointMap.latitude" from-field="parameters.lat"/>
-            <set field="createGeoPointMap.longitude" from-field="parameters.lng"/>
+            <set field="createGeoPointMap.latitude" from-field="parameters.lat" locale="en"/>
+            <set field="createGeoPointMap.longitude" from-field="parameters.lng" locale="en"/>
             <call-service service-name="createGeoPoint" in-map-name="createGeoPointMap">
                 <result-to-field result-name="geoPointId" field="geoPointId"/>
             </call-service>
@@ -143,8 +143,8 @@ under the License.
         <else>
             <set field="updateGeoPointMap.geoPointId" from-field="parameters.geoPointId"/>
             <set field="updateGeoPointMap.dataSourceId" value="GEOPT_GOOGLE"/>
-            <set field="updateGeoPointMap.latitude" from-field="parameters.lat"/>
-            <set field="updateGeoPointMap.longitude" from-field="parameters.lng"/>
+            <set field="updateGeoPointMap.latitude" from-field="parameters.lat" locale="en"/>
+            <set field="updateGeoPointMap.longitude" from-field="parameters.lng" locale="en"/>
             <call-service service-name="updateGeoPoint" in-map-name="updateGeoPointMap"/>
         </else>
         </if-empty>

Modified: ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy (original)
+++ ofbiz/branches/release13.07/applications/party/webapp/partymgr/WEB-INF/actions/party/GetGeoLocation.groovy Wed Jan  1 21:31:41 2014
@@ -23,14 +23,18 @@ import org.ofbiz.base.util.*;
 import org.ofbiz.base.util.string.*;
 import org.ofbiz.party.contact.ContactHelper;
 import org.ofbiz.common.geo.*;
+import java.text.NumberFormat;
 
 if (partyId) {
     context.partyId = partyId;
     latestGeoPoint = GeoWorker.findLatestGeoPoint(delegator, "PartyAndGeoPoint", "partyId", partyId, null, null);
     if (latestGeoPoint) {
         context.geoPointId = latestGeoPoint.geoPointId;
-        context.latitude = latestGeoPoint.latitude;
-        context.longitude = latestGeoPoint.longitude;
+        NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
+        nf.setMinimumFractionDigits(5);
+        nf.setMaximumFractionDigits(10);
+        context.latitude = nf.format(latestGeoPoint.latitude);
+        context.longitude = nf.format(latestGeoPoint.longitude);
     } else {
         context.latitude = 0;
         context.longitude = 0;

Modified: ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editGeoLocation.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editGeoLocation.ftl?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editGeoLocation.ftl (original)
+++ ofbiz/branches/release13.07/applications/party/webapp/partymgr/party/editGeoLocation.ftl Wed Jan  1 21:31:41 2014
@@ -121,7 +121,7 @@ under the License.
         <div align="center" id="map" style="border:1px solid #979797; background-color:#e5e3df; width:500px; height:450px; margin:2em auto;"><br/></div>
         <form action="#" onsubmit="showAddress(this.address.value); return false">
             <input type="text" size="50" name="address"/>
-            <input type="submit" value="Search"/>
+            <input type="submit" value="${uiLabelMap.CommonSearch}"/>
         </form>
         <br/><br/>
         <form id="updateMapForm" method="post" action="<@ofbizUrl>editGeoLocation</@ofbizUrl>">

Modified: ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd (original)
+++ ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd Wed Jan  1 21:31:41 2014
@@ -1218,6 +1218,16 @@ under the License.
                     </xs:documentation>
                 </xs:annotation>
             </xs:attribute>
+            <xs:attribute type="xs:string" name="locale">
+                <xs:annotation>
+                    <xs:documentation>
+                        A locale value (eg: en). The locale allows to pass values whose types are locale dependent (like Float, etc.).
+                        Defaults to the environment locale.
+                        
+                        Optional. Attribute types: constant, ${expression}.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
             <xs:attribute name="set-if-null" type="booleanConst">
                 <xs:annotation>
                     <xs:documentation>

Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java (original)
+++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/MethodContext.java Wed Jan  1 21:31:41 2014
@@ -183,6 +183,10 @@ public final class MethodContext {
         return this.locale;
     }
 
+    public void setLocale(Locale locale) {
+        this.locale = locale;
+    }
+
     public int getMethodType() {
         return this.methodType;
     }

Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java (original)
+++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java Wed Jan  1 21:31:41 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;
@@ -76,6 +77,7 @@ public final class SetOperation extends
 
     private final FlexibleStringExpander defaultFse;
     private final FlexibleStringExpander formatFse;
+    private final FlexibleStringExpander localeFse;
     private final FlexibleMapAccessor<Object> fieldFma;
     private final FlexibleMapAccessor<Object> fromFma;
     private final Scriptlet scriptlet;
@@ -90,7 +92,7 @@ public final class SetOperation extends
         if (MiniLangValidate.validationOn()) {
             MiniLangValidate.deprecatedAttribute(simpleMethod, element, "from-field", "replace with \"from\"");
             MiniLangValidate.deprecatedAttribute(simpleMethod, element, "default-value", "replace with \"default\"");
-            MiniLangValidate.attributeNames(simpleMethod, element, "field", "from-field", "from", "value", "default-value", "default", "format", "type", "set-if-null", "set-if-empty");
+            MiniLangValidate.attributeNames(simpleMethod, element, "field", "from-field", "from", "value", "default-value", "default", "format", "type", "set-if-null", "set-if-empty", "locale");
             MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
             MiniLangValidate.requireAnyAttribute(simpleMethod, element, "from-field", "from", "value");
             MiniLangValidate.constantPlusExpressionAttributes(simpleMethod, element, "value");
@@ -114,6 +116,7 @@ public final class SetOperation extends
         this.valueFse = FlexibleStringExpander.getInstance(element.getAttribute("value"));
         this.defaultFse = FlexibleStringExpander.getInstance(element.getAttribute("default"));
         this.formatFse = FlexibleStringExpander.getInstance(element.getAttribute("format"));
+        this.localeFse = FlexibleStringExpander.getInstance(element.getAttribute("locale"));
         this.type = element.getAttribute("type");
         Class<?> targetClass = null;
         if (!this.type.isEmpty() && !"NewList".equals(this.type) && !"NewMap".equals(this.type)) {
@@ -141,6 +144,10 @@ public final class SetOperation extends
                 Debug.logWarning(exc, "Error evaluating scriptlet [" + this.scriptlet + "]: " + exc, module);
             }
         } else if (!this.fromFma.isEmpty()) {
+            Locale locale = methodContext.getLocale();
+            if (!this.localeFse.isEmpty()) {
+                methodContext.setLocale(new Locale(this.localeFse.expandString(methodContext.getEnvMap())));
+            }
             newValue = this.fromFma.get(methodContext.getEnvMap());
             if (Debug.verboseOn())
                 Debug.logVerbose("In screen getting value for field from [" + this.fromFma.toString() + "]: " + newValue, module);

Modified: ofbiz/branches/release13.07/framework/widget/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/widget/dtd/widget-form.xsd?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/branches/release13.07/framework/widget/dtd/widget-form.xsd Wed Jan  1 21:31:41 2014
@@ -1843,6 +1843,16 @@ under the License.
                     </xs:restriction>
                 </xs:simpleType>
             </xs:attribute>
+            <xs:attribute type="xs:string" name="locale">
+                <xs:annotation>
+                    <xs:documentation>
+                        A locale value (eg: en). The locale allows to pass values with types which are locale dependent (like Float, etc.).
+                        Defaults to the environment locale. Works only if a type which makes sense is also passed.
+                        
+                        Optional. Attribute types: constant, ${expression}.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
         </xs:complexType>
     </xs:element>
 

Modified: ofbiz/branches/release13.07/framework/widget/dtd/widget-screen.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/widget/dtd/widget-screen.xsd?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/widget/dtd/widget-screen.xsd (original)
+++ ofbiz/branches/release13.07/framework/widget/dtd/widget-screen.xsd Wed Jan  1 21:31:41 2014
@@ -346,6 +346,16 @@ under the License.
                     </xs:restriction>
                 </xs:simpleType>
             </xs:attribute>
+            <xs:attribute type="xs:string" name="locale">
+                <xs:annotation>
+                    <xs:documentation>
+                        A locale value (eg: en). The locale allows to pass values with types which are locale dependent (like Float, etc.).
+                        Defaults to the environment locale. Works only if a type which makes sense is also passed.
+                        
+                        Optional. Attribute types: constant, ${expression}.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
         </xs:complexType>
     </xs:element>
     <xs:element name="property-map" substitutionGroup="AllActions">

Modified: ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java (original)
+++ ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java Wed Jan  1 21:31:41 2014
@@ -33,7 +33,6 @@ import javax.servlet.http.HttpSession;
 import javolution.util.FastList;
 import javolution.util.FastMap;
 
-import org.w3c.dom.Element;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.ObjectType;
@@ -59,6 +58,7 @@ import org.ofbiz.minilang.method.MethodC
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.ModelService;
+import org.w3c.dom.Element;
 
 @SuppressWarnings("serial")
 public abstract class ModelWidgetAction implements Serializable {
@@ -121,6 +121,7 @@ public abstract class ModelWidgetAction
         protected FlexibleStringExpander valueExdr;
         protected FlexibleStringExpander defaultExdr;
         protected FlexibleStringExpander globalExdr;
+        protected FlexibleStringExpander localeExdr;
         protected String type;
         protected String toScope;
         protected String fromScope;
@@ -132,6 +133,7 @@ public abstract class ModelWidgetAction
             this.valueExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("value"));
             this.defaultExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("default-value"));
             this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global"));
+            this.localeExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("locale"));
             this.type = setElement.getAttribute("type");
             this.toScope = setElement.getAttribute("to-scope");
             this.fromScope = setElement.getAttribute("from-scope");
@@ -184,7 +186,11 @@ public abstract class ModelWidgetAction
                     newValue = FastList.newInstance();
                 } else {
                     try {
-                        newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true);
+                        Locale locale = (Locale) context.get("locale");
+                        if (!this.localeExdr.isEmpty()) {
+                            locale = new Locale(this.globalExdr.expandString(context));
+                        }
+                        newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), locale, true);
                     } catch (GeneralException e) {
                         String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString();
                         Debug.logError(e, errMsg, module);

Modified: ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=1554682&r1=1554681&r2=1554682&view=diff
==============================================================================
--- ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original)
+++ ofbiz/branches/release13.07/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Wed Jan  1 21:31:41 2014
@@ -116,6 +116,7 @@ public abstract class ModelFormAction {
         protected FlexibleStringExpander valueExdr;
         protected FlexibleStringExpander defaultExdr;
         protected FlexibleStringExpander globalExdr;
+        protected FlexibleStringExpander localeExdr;
         protected String type;
 
         public SetField(ModelForm modelForm, Element setElement) {
@@ -125,6 +126,7 @@ public abstract class ModelFormAction {
             this.valueExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("value"));
             this.defaultExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("default-value"));
             this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global"));
+            this.localeExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("locale"));
             this.type = setElement.getAttribute("type");
             if (!this.fromField.isEmpty() && !this.valueExdr.isEmpty()) {
                 throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a screen widget");
@@ -157,7 +159,11 @@ public abstract class ModelFormAction {
                     newValue = FastList.newInstance();
                 } else {
                     try {
-                        newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true);
+                        Locale locale = (Locale) context.get("locale");
+                        if (!this.localeExdr.isEmpty()) {
+                            locale = new Locale(this.globalExdr.expandString(context));
+                        }
+                        newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), locale, true);
                     } catch (GeneralException e) {
                         String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString();
                         Debug.logError(e, errMsg, module);