You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2007/02/06 12:19:32 UTC

svn commit: r504079 - in /tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib: InsertAttributeTag.java PutAttributeTag.java PutListTag.java

Author: apetrelli
Date: Tue Feb  6 03:19:25 2007
New Revision: 504079

URL: http://svn.apache.org/viewvc?view=rev&rev=504079
Log:
Better management of ComponentContexts inside attributes.

Modified:
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/InsertAttributeTag.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutAttributeTag.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/InsertAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/InsertAttributeTag.java?view=diff&rev=504079&r1=504078&r2=504079
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/InsertAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/InsertAttributeTag.java Tue Feb  6 03:19:25 2007
@@ -46,6 +46,8 @@
     protected String name;
     
     protected Object value = null;
+    
+    protected ComponentContext evaluatingContext;
 
     public void setName(String value) {
         this.name = value;
@@ -80,17 +82,20 @@
     }
 
     protected void render() throws JspException, TilesException, IOException {
-        ComponentContext context = container.getComponentContext(pageContext);
         ComponentAttribute attr = (ComponentAttribute) value;
-        if (attr == null) {
-            attr = context.getAttribute(name);
+        if (attr == null && evaluatingContext != null) {
+            attr = evaluatingContext.getAttribute(name);
         }
         if (attr == null && ignore) {
             return;
         }
 
         if (attr == null) {
-            throw new TilesException("Attribute '" + name + "' not found.");
+            if (name != null) {
+                throw new TilesException("Attribute '" + name + "' not found.");
+            } else {
+                throw new TilesException("No attribute name or value has been provided.");
+            }
         }
 
         container.render(pageContext, attr);
@@ -98,13 +103,10 @@
 
     @Override
     protected void startContext(PageContext context) {
+        
         if (container != null) {
-            componentContext = container.getComponentContext(context);
+            evaluatingContext = container.getComponentContext(context);
         }
-    }
-
-    @Override
-    protected void endContext(PageContext context) {
-        // Do nothing
+        super.startContext(context);
     }
 }

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutAttributeTag.java?view=diff&rev=504079&r1=504078&r2=504079
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutAttributeTag.java Tue Feb  6 03:19:25 2007
@@ -29,6 +29,7 @@
 import org.apache.commons.logging.LogFactory;
 
 import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.tagext.TagSupport;
 
 /**
@@ -136,6 +137,18 @@
             type = "string";
         }
         return (SKIP_BODY);
+    }
+
+    @Override
+    protected void startContext(PageContext context) {
+        if (container != null) {
+            componentContext = container.getComponentContext(context);
+        }
+    }
+
+    @Override
+    protected void endContext(PageContext context) {
+        // Do nothing
     }
 
     protected void execute() throws JspException {

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java?view=diff&rev=504079&r1=504078&r2=504079
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/taglib/PutListTag.java Tue Feb  6 03:19:25 2007
@@ -29,6 +29,7 @@
 import java.util.List;
 
 import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
 
 /**
  * PutList tag implementation.
@@ -93,6 +94,18 @@
             nestedTag.getType());
 
         this.addValue(attribute);	
+    }
+
+    @Override
+    protected void startContext(PageContext context) {
+        if (container != null) {
+            componentContext = container.getComponentContext(context);
+        }
+    }
+
+    @Override
+    protected void endContext(PageContext context) {
+        // Do nothing
     }
 
 	private void addValue( ComponentAttribute attribute ) {