You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ap...@apache.org on 2006/12/02 23:41:01 UTC

svn commit: r481655 - /struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java

Author: apetrelli
Date: Sat Dec  2 14:41:00 2006
New Revision: 481655

URL: http://svn.apache.org/viewvc?view=rev&rev=481655
Log:
SB-100
Corrected Tiles configuration files loading order.

Modified:
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java?view=diff&rev=481655&r1=481654&r2=481655
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java Sat Dec  2 14:41:00 2006
@@ -201,11 +201,13 @@
 
         processedLocales.add(locale);
         List<String> postfixes = calculatePostfixes(locale);
-        for (Object source : sources) {
-            URL url = (URL) source;
-            String path = url.toExternalForm();
+        Map localeDefsMap = new HashMap();
+        for (Object postfix : postfixes) {
+        	// For each postfix, all the sources must be loaded.
+            for (Object source : sources) {
+                URL url = (URL) source;
+                String path = url.toExternalForm();
 
-            for (Object postfix : postfixes) {
                 String newPath = concatPostfix(path, (String) postfix);
                 try {
                     URL newUrl = new URL(newPath);
@@ -213,9 +215,13 @@
                     connection.connect();
                     lastModifiedDates.put(newUrl.toExternalForm(),
                         connection.getLastModified());
+                    
+                    // Definition must be collected, starting from the base
+                    // source up to the last localized file.
                     Map defsMap = reader.read(connection.getInputStream());
-                    definitions.addDefinitions(defsMap,
-                        tilesContext.getRequestLocale());
+                    if (defsMap != null) {
+                    	localeDefsMap.putAll(defsMap);
+                    }
                 } catch (FileNotFoundException e) {
                     // File not found. continue.
                 } catch (IOException e) {
@@ -224,6 +230,11 @@
                 }
             }
         }
+        
+        // At the end definitions loading, they can be assigned to
+        // ComponentDefinitions implementation, to allow inheritance resolution.
+        definitions.addDefinitions(localeDefsMap,
+        		tilesContext.getRequestLocale());
     }
 
     /**
@@ -311,6 +322,9 @@
         final String variant = locale.getVariant();
         final int variantLength = variant.length();
 
+        // The default configuration file must be loaded to allow correct
+        // definition inheritance.
+        result.add("");
         if (languageLength + countryLength + variantLength == 0) {
             //The locale is "", "", "".
             return result;