Anonymous avatar Anonymous committed 8024bd7

shitload of bug fixes and stuff. Highlights are:
* upgraded to oscore 2.2.4 to fix NPE problem
* upgraded to final ognl 2.6.5
* reloading resource bundles (in the ghetto-fabulous way) option placed in XWork
* themes and templates now done just like 1.x
* UI label attr no longer required
* simple theme is now extended by the xhtml theme for all you "bare-bones" kids
* namespace attribute in ww:action tag is evaluated
* name attr is no longer doulbe evaluated for the form tag

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@231 e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (5)

     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/lib/core/oscore-2.2.3.jar!/" />
+          <root url="jar://$MODULE_DIR$/lib/core/ognl-2.6.5.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
     <orderEntry type="module-library">
       <library>
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/lib/core/ognl-2.6.5.jar!/" />
+          <root url="jar://$MODULE_DIR$/lib/core/oscore-2.2.4.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
Add a comment to this file

lib/core/ognl-2.6.5.jar

Binary file modified.

Add a comment to this file

lib/core/oscore-2.2.3.jar

Binary file removed.

Add a comment to this file

lib/core/oscore-2.2.4.jar

Binary file added.

src/java/com/opensymphony/xwork/util/LocalizedTextUtil.java

 import com.opensymphony.xwork.Action;
 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.ModelDriven;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.text.MessageFormat;
-
 import java.util.*;
 
 
     private static final List DEFAULT_RESOURCE_BUNDLES = Collections.synchronizedList(new ArrayList());
     private static final Log LOG = LogFactory.getLog(LocalizedTextUtil.class);
 
+    private static boolean reloadBundles = false;
+
     static {
         DEFAULT_RESOURCE_BUNDLES.add("com/opensymphony/xwork/xwork-messages");
     }
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
+    public static void setReloadBundles(boolean reloadBundles) {
+        LocalizedTextUtil.reloadBundles = reloadBundles;
+    }
+
     public static void addDefaultResourceBundle(String resourceBundleName) {
         //make sure this doesn't get added more than once
         DEFAULT_RESOURCE_BUNDLES.remove(resourceBundleName);
         }
     }
 
+    private static void reloadBundles(ResourceBundle resource) {
+        if (reloadBundles) {
+            try {
+                Class klass = resource.getClass().getSuperclass();
+                Field field = klass.getDeclaredField("cacheList");
+                field.setAccessible(true);
+                Object cache = field.get(null);
+                Method clearMethod = cache.getClass().getMethod("clear", new Class[0]);
+                clearMethod.invoke(cache, new Object[0]);
+            } catch (Exception e) {
+                LOG.error("Could not reload resource bundles", e);
+            }
+        }
+    }
+
     public static String findDefaultText(String aTextName, Locale locale) throws MissingResourceException {
         MissingResourceException e = null;
         List localList = new ArrayList(DEFAULT_RESOURCE_BUNDLES);
 
             try {
                 ResourceBundle bundle = findResourceBundle(bundleName, locale);
-
+                reloadBundles(bundle);
                 return bundle.getString(aTextName);
             } catch (MissingResourceException ex) {
                 e = ex;
         do {
             try {
                 ResourceBundle bundle = findResourceBundle(clazz.getName(), locale);
+                reloadBundles(bundle);
                 String message = TextParseUtil.translateVariables(bundle.getString(aTextName), valueStack);
 
                 return MessageFormat.format(message, args);
                     for (int x = 0; x < interfaces.length; x++) {
                         try {
                             ResourceBundle bundle = findResourceBundle(interfaces[x].getName(), locale);
+                            reloadBundles(bundle);
                             String message = TextParseUtil.translateVariables(bundle.getString(aTextName), valueStack);
 
                             return MessageFormat.format(message, args);
                     // search up model class hierarchy
                     try {
                         ResourceBundle bundle = findResourceBundle(clazz.getName(), locale);
+                        reloadBundles(bundle);
                         String message = TextParseUtil.translateVariables(bundle.getString(aTextName), valueStack);
 
                         return MessageFormat.format(message, args);
         OgnlValueStack valueStack = ActionContext.getContext().getValueStack();
 
         try {
+            reloadBundles(bundle);
             String message = TextParseUtil.translateVariables(bundle.getString(aTextName), valueStack);
 
             return MessageFormat.format(message, args);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.