Author: jdonnerstag
Date: Sat Oct 24 08:42:24 2009
New Revision: 829322

URL: http://svn.apache.org/viewvc?rev=829322&view=rev
Log:
fixed PackageStringResourceLoader does not look up to superclasses
Issue: WICKET-2539

Modified:
    
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java?rev=829322&r1=829321&r2=829322&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/resource/loader/PackageStringResourceLoader.java
 Sat Oct 24 08:42:24 2009
@@ -64,52 +64,63 @@
         *      java.lang.String, java.util.Locale, java.lang.String)
         */
        @Override
-       public String loadStringResource(final Class<?> clazz, final String 
key, final Locale locale,
+       public String loadStringResource(Class<?> clazz, final String key, 
final Locale locale,
                final String style)
        {
                if (clazz == null)
                {
                        return null;
                }
-
-               String packageName = clazz.getPackage().getName();
-               packageName = packageName.replace('.', '/');
-
                // Load the properties associated with the path
                IPropertiesFactory propertiesFactory = Application.get()
                        .getResourceSettings()
                        .getPropertiesFactory();
 
-               while (packageName.length() > 0)
+               while (true)
                {
-                       // Create the base path
-                       String path = packageName + "/" + filename;
+                       String packageName = clazz.getPackage().getName();
+                       packageName = packageName.replace('.', '/');
 
-                       // Iterator over all the combinations
-                       ResourceNameIterator iter = new 
ResourceNameIterator(path, style, locale, null);
-                       while (iter.hasNext())
+                       while (packageName.length() > 0)
                        {
-                               String newPath = iter.next();
+                               // Create the base path
+                               String path = packageName + "/" + filename;
 
-                               final Properties props = 
propertiesFactory.load(clazz, newPath);
-                               if (props != null)
+                               // Iterator over all the combinations
+                               ResourceNameIterator iter = new 
ResourceNameIterator(path, style, locale, null);
+                               while (iter.hasNext())
                                {
-                                       // Lookup the value
-                                       String value = props.getString(key);
-                                       if (value != null)
+                                       String newPath = iter.next();
+
+                                       final Properties props = 
propertiesFactory.load(clazz, newPath);
+                                       if (props != null)
                                        {
-                                               if (log.isDebugEnabled())
+                                               // Lookup the value
+                                               String value = 
props.getString(key);
+                                               if (value != null)
                                                {
-                                                       log.debug("Found 
resource from: " + props + "; key: " + key);
-                                               }
+                                                       if 
(log.isDebugEnabled())
+                                                       {
+                                                               
log.debug("Found resource from: " + props + "; key: " + key);
+                                                       }
 
-                                               return value;
+                                                       return value;
+                                               }
                                        }
                                }
+
+                               // Didn't find the key yet, continue searching 
if possible
+                               packageName = Strings.beforeLast(packageName, 
'/');
                        }
 
-                       // Didn't find the key yet, continue searching if 
possible
-                       packageName = Strings.beforeLast(packageName, '/');
+                       // Move to the next superclass
+                       clazz = clazz.getSuperclass();
+
+                       if (clazz == null)
+                       {
+                               // nothing more to search, done
+                               break;
+                       }
                }
 
                // not found


Reply via email to