struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddew...@apache.org
Subject svn commit: r473011 - in /struts/sandbox/trunk/tiles: tiles-core/src/main/java/org/apache/tiles/definition/ tiles-core/src/main/java/org/apache/tiles/impl/mgmt/ tiles-core/src/main/java/org/apache/tiles/taglib/ tiles-core/src/main/java/org/apache/tiles...
Date Thu, 09 Nov 2006 18:36:38 GMT
Author: ddewolf
Date: Thu Nov  9 10:36:37 2006
New Revision: 473011

URL: http://svn.apache.org/viewvc?view=rev&rev=473011
Log:
Fixing several jsp defined definition tests

Modified:
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java
    struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java?view=diff&rev=473011&r1=473010&r2=473011
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
Thu Nov  9 10:36:37 2006
@@ -103,9 +103,12 @@
      */
     public ComponentDefinition getDefinition(String name, Locale locale) {
         ComponentDefinition definition = null;
-        Map localeSpecificMap = (Map) localeSpecificDefinitions.get(locale);
-        if (localeSpecificMap != null) {
-            definition = (ComponentDefinition) localeSpecificMap.get(name);
+
+        if (locale != null) {
+            Map localeSpecificMap = localeSpecificDefinitions.get(locale);
+            if (localeSpecificMap != null) {
+                definition = (ComponentDefinition) localeSpecificMap.get(name);
+            }
         }
 
         if (definition == null) {
@@ -156,13 +159,13 @@
     }
 
     public void resolveAttributeDependencies() {
-        for (ComponentDefinition def: baseDefinitions.values()) {
+        for (ComponentDefinition def : baseDefinitions.values()) {
             Map<String, ComponentAttribute> attributes = def.getAttributes();
-            for (ComponentAttribute attr: attributes.values()) {
+            for (ComponentAttribute attr : attributes.values()) {
                 if (isDefinitionType(attr)) {
-                        ComponentDefinition subDef =
-                            getDefinitionByAttribute(attr);
-                        attr.setAttributes(subDef.getAttributes());
+                    ComponentDefinition subDef =
+                        getDefinitionByAttribute(attr);
+                    attr.setAttributes(subDef.getAttributes());
                 }
             }
         }
@@ -170,11 +173,11 @@
 
     private boolean isDefinitionType(ComponentAttribute attr) {
         boolean explicit = (attr.getType() != null &&
-               (attr.getType().equalsIgnoreCase("definition") ||
+            (attr.getType().equalsIgnoreCase("definition") ||
                 attr.getType().equalsIgnoreCase("instance")));
 
         boolean implicit =
-                attr.getType() == null &&
+            attr.getType() == null &&
                 attr.getValue() != null &&
                 baseDefinitions.containsKey(attr.getValue().toString());
 

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=473011&r1=473010&r2=473011
==============================================================================
--- 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
Thu Nov  9 10:36:37 2006
@@ -21,16 +21,21 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.TilesException;
 import org.apache.tiles.context.TilesRequestContext;
 import org.apache.tiles.definition.digester.DigesterDefinitionsReader;
 import org.apache.tiles.util.ClassUtil;
-import org.apache.tiles.TilesException;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLConnection;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * {@link DefinitionsFactory DefinitionsFactory} implementation
@@ -127,10 +132,14 @@
         throws DefinitionsFactoryException {
 
         ComponentDefinitions definitions = getComponentDefinitions();
-        Locale locale = tilesContext.getRequestLocale();
-        if (!isLocaleProcessed(tilesContext)) {
-            synchronized (definitions) {
-                addDefinitions(definitions, tilesContext);
+        Locale locale = null;
+
+        if (tilesContext != null) {
+            tilesContext.getRequestLocale();
+            if (!isLocaleProcessed(tilesContext)) {
+                synchronized (definitions) {
+                    addDefinitions(definitions, tilesContext);
+                }
             }
         }
 

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java?view=diff&rev=473011&r1=473010&r2=473011
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
Thu Nov  9 10:36:37 2006
@@ -42,10 +42,19 @@
         return getFactory().getDefinition(definition, request);
     }
 
-    public void addDefinition(ComponentDefinition definition) {
+    public void addDefinition(ComponentDefinition definition)
+        throws DefinitionsFactoryException {
         validate(definition);
 
-        if(definition.getExtends() != null) {
+        if(definition.isExtending()) {
+            this.resolveInheritance(definition);
+        }
+
+        for(ComponentAttribute attr : definition.getAttributes().values()) {
+            if(ComponentAttribute.DEFINITION.equals(attr.getType())) {
+                ComponentDefinition d = getDefinition(attr.getValue().toString(), null);
+                attr.setAttributes(d.getAttributes());
+            }
         }
 
         definitions.put(definition.getName(), definition);

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java?view=diff&rev=473011&r1=473010&r2=473011
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
Thu Nov  9 10:36:37 2006
@@ -20,11 +20,10 @@
 
 package org.apache.tiles.taglib;
 
-import org.apache.tiles.context.jsp.JspUtil;
 import org.apache.tiles.ComponentAttribute;
-import org.apache.tiles.TilesException;
 import org.apache.tiles.ComponentContext;
-import org.apache.tiles.taglib.RenderTagSupport;
+import org.apache.tiles.TilesException;
+import org.apache.tiles.context.jsp.JspUtil;
 
 import javax.servlet.jsp.JspException;
 import java.io.IOException;
@@ -72,31 +71,31 @@
     protected void render() throws JspException, TilesException, IOException {
         ComponentContext context = container.getComponentContext(pageContext);
         ComponentAttribute attr = context.getAttribute(name);
-        if(attr == null && ignore) {
+        if (attr == null && ignore) {
             return;
         }
 
-        if(attr == null) {
-            throw new TilesException("Attribute '"+name+"' not found.");
+        if (attr == null) {
+            throw new TilesException("Attribute '" + name + "' not found.");
         }
 
         String type = calculateType(attr);
-        if("string".equalsIgnoreCase(type)) {
+        if ("string".equalsIgnoreCase(type)) {
             pageContext.getOut().print(attr.getValue());
 
-        } else if(isDefinition(attr)) {
-            if(template != null) {
+        } else if (isDefinition(attr)) {
+            if (template != null) {
                 attr.setValue(template);
             }
-            
+
             Map<String, ComponentAttribute> attrs = attr.getAttributes();
-            if(attrs != null) {
-                for(Map.Entry<String, ComponentAttribute> a : attrs.entrySet()) {
+            if (attrs != null) {
+                for (Map.Entry<String, ComponentAttribute> a : attrs.entrySet()) {
                     context.putAttribute(a.getKey(), a.getValue());
                 }
             }
             container.render(pageContext, attr.getValue().toString());
-            
+
         } else {
             JspUtil.doInclude(pageContext, attr.getValue().toString(), flush);
         }
@@ -114,33 +113,18 @@
             Object valueContent = attr.getValue();
             if (valueContent instanceof String) {
                 String valueString = (String) valueContent;
-                if (valueString.startsWith("/")) {
+                if (container.isValidDefinition(pageContext, valueString)) {
+                    type = ComponentAttribute.DEFINITION;
+                } else if (valueString.startsWith("/")) {
                     type = ComponentAttribute.TEMPLATE;
                 } else {
-                    if (container.isValidDefinition(pageContext, valueString)) {
-                        type = ComponentAttribute.DEFINITION;
-                        attr.setValue(valueString);
-                    } else {
-                        type = ComponentAttribute.STRING;
-                    }
+                    type = ComponentAttribute.STRING;
                 }
             }
             if (type == null) {
                 throw new JspException("Unrecognized type for attribute value "
                     + attr.getValue());
             }
-            attr.setType(type);
-        } else if (type.equalsIgnoreCase("definition")) {
-            Object valueContent = attr.getValue();
-            if (valueContent instanceof String) {
-                // FIXME If the value is the name of a definition, the
-                // corresponding definition should be put as the value of the
-                // attribute
-                if (!container.isValidDefinition(pageContext, (String) valueContent))
-                    throw new JspException("Cannot find any definition named '"
-                        + valueContent + "'");
-            }
-            attr.setValue(valueContent);
         }
         return type;
     }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java?view=diff&rev=473011&r1=473010&r2=473011
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/definition/DefinitionTag.java
Thu Nov  9 10:36:37 2006
@@ -121,7 +121,7 @@
     }
 
     /**
-     * TODO: Implement mutable container features.
+     *
      *
      * @return
      */

Modified: struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp?view=diff&rev=473011&r1=473010&r2=473011
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp (original)
+++ struts/sandbox/trunk/tiles/tiles-test/src/main/webapp/index.jsp Thu Nov  9 10:36:37 2006
@@ -43,13 +43,12 @@
 
     <h2>Container Management Tags</h2>
     <a href="testinitcontainer.jsp">Test Initialize Container</a><br/>
-
-    <h2>Currently not working tests</h2>
     <a href="testdef.jsp">Test Definition Tag</a><br/>
-    <!-- Currently all the tests work.-->
     <a href="testinsertdefinition_composite_tags_includes_configured.jsp">Test Insert
Definition that contains another definition inside (configured via tiles-defs.xml) using JSP
tags</a><br/>
-    <a href="testinsertdefinition_composite_tags_includes_configured_notype.jsp">Test
Insert Definition that contains another definition inside (configured via tiles-defs.xml)
using JSP tags without types</a><br/>
     <a href="testinsertdefinition_composite_tags.jsp">Test Insert Definition that contains
another definition inside using JSP tags</a><br/>
+
+    <h2>Currently not working tests</h2>
+    <a href="testinsertdefinition_composite_tags_includes_configured_notype.jsp">Test
Insert Definition that contains another definition inside (configured via tiles-defs.xml)
using JSP tags without types</a><br/>
     <a href="testinsertdefinition_composite_tags_notype.jsp">Test Insert Definition
that contains another definition inside using JSP tags without types</a><br/></body>
 
 </html>



Mime
View raw message