Revision: 1250
          http://stripes.svn.sourceforge.net/stripes/?rev=1250&view=rev
Author:   bengunter
Date:     2010-05-25 12:58:06 +0000 (Tue, 25 May 2010)

Log Message:
-----------
STS-391: Fixed broken layout when a layout-render tag was a child of a 
layout-component tag. Under such circumstances, the inner layout did not render 
at all.

Modified Paths:
--------------
    
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutRenderTag.java
    branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutTag.java

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutRenderTag.java
===================================================================
--- 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutRenderTag.java
  2010-05-24 14:51:30 UTC (rev 1249)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutRenderTag.java
  2010-05-25 12:58:06 UTC (rev 1250)
@@ -60,7 +60,8 @@
             LayoutContext context = LayoutContext.lookup(pageContext);
             boolean contextNew = false;
 
-            if (context == null || !context.isComponentRenderPhase()) {
+            if (context == null || !context.isComponentRenderPhase()
+                    || context.isComponentRenderPhase() && 
isChildOfComponent()) {
                 context = LayoutContext.push(this);
                 contextNew = true;
             }

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutTag.java
===================================================================
--- 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutTag.java    
    2010-05-24 14:51:30 UTC (rev 1249)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutTag.java    
    2010-05-25 12:58:06 UTC (rev 1250)
@@ -28,8 +28,7 @@
  * @since Stripes 1.5.4
  */
 public abstract class LayoutTag extends StripesTagSupport {
-    private LayoutDefinitionTag parentDefinitionTag;
-    private LayoutRenderTag parentRenderTag;
+    private LayoutTag layoutAncestor;
 
     /** Get the context-relative path of the page that invoked this tag. */
     public String getCurrentPagePath() {
@@ -40,50 +39,28 @@
         return path;
     }
 
-    /** True if this tag is executing as a child of the {...@link 
LayoutDefinitionTag}. */
-    public boolean isChildOfDefinition() {
-        // Check for cached results
-        if (this.parentDefinitionTag != null)
-            return true;
-        else if (this.parentRenderTag != null)
-            return false;
+    /**
+     * True if the nearest ancestor of this tag that is an instance of 
{...@link LayoutTag} is also an
+     * instance of {...@link LayoutRenderTag}.
+     */
+    public boolean isChildOfRender() {
+        return getLayoutAncestor() instanceof LayoutRenderTag;
+    }
 
-        // Search the tag stack for the nearest layout tag ancestor
-        for (Tag tag = getParent(); tag != null; tag = tag.getParent()) {
-            if (tag instanceof LayoutDefinitionTag) {
-                this.parentDefinitionTag = (LayoutDefinitionTag) tag;
-                return true;
-            }
-            else if (tag instanceof LayoutRenderTag) {
-                this.parentRenderTag = (LayoutRenderTag) tag;
-                return false;
-            }
-        }
-
-        return false;
+    /**
+     * True if the nearest ancestor of this tag that is an instance of 
{...@link LayoutTag} is also an
+     * instance of {...@link LayoutDefinitionTag}.
+     */
+    public boolean isChildOfDefinition() {
+        return getLayoutAncestor() instanceof LayoutDefinitionTag;
     }
 
-    /** True if this tag is executing as a child of the {...@link 
LayoutRenderTag}. */
-    public boolean isChildOfRender() {
-        // Check for cached results
-        if (this.parentRenderTag != null)
-            return true;
-        else if (this.parentDefinitionTag != null)
-            return false;
-
-        // Search the tag stack for the nearest layout tag ancestor
-        for (Tag tag = getParent(); tag != null; tag = tag.getParent()) {
-            if (tag instanceof LayoutDefinitionTag) {
-                this.parentDefinitionTag = (LayoutDefinitionTag) tag;
-                return false;
-            }
-            else if (tag instanceof LayoutRenderTag) {
-                this.parentRenderTag = (LayoutRenderTag) tag;
-                return true;
-            }
-        }
-
-        return false;
+    /**
+     * True if the nearest ancestor of this tag that is an instance of 
{...@link LayoutTag} is also an
+     * instance of {...@link LayoutComponentTag}.
+     */
+    public boolean isChildOfComponent() {
+        return getLayoutAncestor() instanceof LayoutComponentTag;
     }
 
     /**
@@ -93,11 +70,14 @@
      */
     @SuppressWarnings("unchecked")
     public <T extends LayoutTag> T getLayoutAncestor() {
-        if (isChildOfRender())
-            return (T) parentRenderTag;
-        else if (isChildOfDefinition())
-            return (T) parentDefinitionTag;
-        else
-            return null;
+        if (layoutAncestor == null) {
+            for (Tag tag = getParent(); tag != null; tag = tag.getParent()) {
+                if (tag instanceof LayoutTag) {
+                    return (T) (this.layoutAncestor = (LayoutTag) tag);
+                }
+            }
+        }
+
+        return (T) layoutAncestor;
     }
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------

_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to