struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [3/3] struts git commit: Adds support for multiple tiles defintions
Date Tue, 05 Apr 2016 06:44:19 GMT
Adds support for multiple tiles defintions


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c12cd619
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c12cd619
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c12cd619

Branch: refs/heads/master
Commit: c12cd61946c883d7cadb69d46c46a3dffb339390
Parents: cfad2f1
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Tue Apr 5 08:44:04 2016 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Tue Apr 5 08:44:04 2016 +0200

----------------------------------------------------------------------
 .../tiles/StrutsTilesContainerFactory.java      | 23 ++++++++++++--------
 1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/c12cd619/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
index fe90d75..a8e77ce 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesContainerFactory.java
@@ -19,6 +19,7 @@
 
 package org.apache.struts2.tiles;
 
+import com.opensymphony.xwork2.util.TextParseUtil;
 import ognl.OgnlException;
 import ognl.OgnlRuntime;
 import ognl.PropertyAccessor;
@@ -71,6 +72,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * Dedicated Struts factory to build Tiles container with support for:
@@ -176,25 +178,28 @@ public class StrutsTilesContainerFactory extends BasicTilesContainerFactory
{
 
     @Override
     protected List<ApplicationResource> getSources(ApplicationContext applicationContext)
{
-        Collection<ApplicationResource> resources = applicationContext.getResources(getTilesDefinitionPattern(applicationContext.getInitParams()));
+        Collection<ApplicationResource> resources = new ArrayList<>();
+
+        Set<String> definitions = getTilesDefinitions(applicationContext.getInitParams());
+        for (String definition : definitions) {
+            resources.addAll(applicationContext.getResources(definition));
+        }
 
         List<ApplicationResource> filteredResources = new ArrayList<>();
-        if (resources != null) {
-            for (ApplicationResource resource : resources) {
-                if (Locale.ROOT.equals(resource.getLocale())) {
-                    filteredResources.add(resource);
-                }
+        for (ApplicationResource resource : resources) {
+            if (Locale.ROOT.equals(resource.getLocale())) {
+                filteredResources.add(resource);
             }
         }
 
         return filteredResources;
     }
 
-    protected String getTilesDefinitionPattern(Map<String, String> params) {
+    protected Set<String> getTilesDefinitions(Map<String, String> params) {
         if (params.containsKey(DefinitionsFactory.DEFINITIONS_CONFIG)) {
-            return params.get(DefinitionsFactory.DEFINITIONS_CONFIG);
+            return TextParseUtil.commaDelimitedStringToSet(params.get(DefinitionsFactory.DEFINITIONS_CONFIG));
         }
-        return TILES_DEFAULT_PATTERN;
+        return TextParseUtil.commaDelimitedStringToSet(TILES_DEFAULT_PATTERN);
     }
 
     protected ELAttributeEvaluator createELEvaluator(ApplicationContext applicationContext)
{


Mime
View raw message