Revision: 1429
          http://stripes.svn.sourceforge.net/stripes/?rev=1429&view=rev
Author:   bengunter
Date:     2011-04-22 19:36:41 +0000 (Fri, 22 Apr 2011)

Log Message:
-----------
Applied fix for STS-817 from 1.5.x branch.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java
    trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutContext.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java
===================================================================
--- 
trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java    
    2011-04-22 19:25:40 UTC (rev 1428)
+++ 
trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java    
    2011-04-22 19:36:41 UTC (rev 1429)
@@ -113,8 +113,24 @@
      * @throws StripesJspException If a {@link LayoutContext} is not found.
      */
     public boolean isCurrentComponent() throws StripesJspException {
-        String name = getContext().getComponent();
-        return name != null && name.equals(getName());
+        final LayoutContext context = getContext();
+        String name = context.getComponent();
+        if (name == null || !name.equals(getName()))
+            return false;
+
+        final List<String> want = context.getComponentPath();
+        if (want == null)
+            return true;
+
+        final LayoutTag parent = getLayoutParent();
+        if (!(parent instanceof LayoutRenderTag))
+            return false;
+
+        final List<String> got = context.getPathToRenderTag((LayoutRenderTag) 
parent);
+        if (got == null)
+            return false;
+
+        return want.equals(got);
     }
 
     /**

Modified: 
trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutContext.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutContext.java     
2011-04-22 19:25:40 UTC (rev 1428)
+++ trunk/stripes/src/net/sourceforge/stripes/tag/layout/LayoutContext.java     
2011-04-22 19:36:41 UTC (rev 1429)
@@ -133,8 +133,24 @@
         this.renderTag = renderTag;
         this.renderPage = renderTag.getCurrentPagePath();
 
+        List<String> path = getPathToRenderTag(renderTag);
+        if (path != null) {
+            this.componentPath = Collections.unmodifiableList(path);
+            log.debug("Path is ", this.componentPath);
+        }
+    }
+
+    /**
+     * Calculate the path to a render tag. The path is a list of names of 
components that must
+     * execute, in order, so that the specified render tag can execute.
+     * 
+     * @param tag The render tag.
+     * @return A list of component names or null if the render tag is not a 
child of a component.
+     */
+    public List<String> getPathToRenderTag(LayoutRenderTag tag) {
         LinkedList<String> path = null;
-        for (LayoutTag parent = renderTag.getLayoutParent(); parent instanceof 
LayoutComponentTag;) {
+
+        for (LayoutTag parent = tag.getLayoutParent(); parent instanceof 
LayoutComponentTag;) {
             if (path == null)
                 path = new LinkedList<String>();
 
@@ -144,10 +160,7 @@
             parent = parent instanceof LayoutRenderTag ? 
parent.getLayoutParent() : null;
         }
 
-        if (path != null) {
-            this.componentPath = Collections.unmodifiableList(path);
-            log.debug("Path is ", this.componentPath);
-        }
+        return path;
     }
 
     /** Get the previous layout context from the stack. */


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

------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been 
demonstrated beyond question. Learn why your peers are replacing JEE 
containers with lightweight application servers - and what you can gain 
from the move. http://p.sf.net/sfu/vmware-sfemails
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to