svn commit: r960190 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java

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

svn commit: r960190 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java

lektran
Author: lektran
Date: Sat Jul  3 09:50:07 2010
New Revision: 960190

URL: http://svn.apache.org/viewvc?rev=960190&view=rev
Log:
Fix ModelMenuAction.PropertyMap, if the map already existed then it was overwritten instead of being added to.  Fixed before merging with ModelWidgetAction so that I can backport to 10.04

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java?rev=960190&r1=960189&r2=960190&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java Sat Jul  3 09:50:07 2010
@@ -44,6 +44,7 @@ import org.ofbiz.base.util.UtilPropertie
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
+import org.ofbiz.base.util.collections.ResourceBundleMapWrapper;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.entity.finder.ByAndFinder;
 import org.ofbiz.entity.finder.ByConditionFinder;
@@ -241,7 +242,7 @@ public abstract class ModelMenuAction {
 
     public static class PropertyMap extends ModelMenuAction {
         protected FlexibleStringExpander resourceExdr;
-        protected FlexibleMapAccessor<Map<String, Object>> mapNameAcsr;
+        protected FlexibleMapAccessor<ResourceBundleMapWrapper> mapNameAcsr;
         protected FlexibleStringExpander globalExdr;
 
         public PropertyMap(ModelMenu modelMenu, Element setElement) {
@@ -259,13 +260,36 @@ public abstract class ModelMenuAction {
 
             Locale locale = (Locale) context.get("locale");
             String resource = this.resourceExdr.expandString(context, locale);
-            Map<String, Object> propertyMap = UtilProperties.getResourceBundleMap(resource, locale);
-            this.mapNameAcsr.put(context, propertyMap);
+
+            ResourceBundleMapWrapper existingPropMap = this.mapNameAcsr.get(context);
+            if (existingPropMap == null) {
+                this.mapNameAcsr.put(context, UtilProperties.getResourceBundleMap(resource, locale, context));
+            } else {
+                try {
+                    existingPropMap.addBottomResourceBundle(resource);
+                } catch (IllegalArgumentException e) {
+                    // log the error, but don't let it kill everything just for a typo or bad char in an l10n file
+                    Debug.logError(e, "Error adding resource bundle [" + resource + "]: " + e.toString(), module);
+                }
+            }
 
             if (global) {
                 Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
                 if (globalCtx != null) {
-                    this.mapNameAcsr.put(globalCtx, propertyMap);
+                    ResourceBundleMapWrapper globalExistingPropMap = this.mapNameAcsr.get(globalCtx);
+                    if (globalExistingPropMap == null) {
+                        this.mapNameAcsr.put(globalCtx, UtilProperties.getResourceBundleMap(resource, locale, context));
+                    } else {
+                        // is it the same object? if not add it in here too...
+                        if (existingPropMap != globalExistingPropMap) {
+                            try {
+                                globalExistingPropMap.addBottomResourceBundle(resource);
+                            } catch (IllegalArgumentException e) {
+                                // log the error, but don't let it kill everything just for a typo or bad char in an l10n file
+                                Debug.logError(e, "Error adding resource bundle [" + resource + "]: " + e.toString(), module);
+                            }
+                        }
+                    }
                 }
             }
         }