Revision: 1428
http://stripes.svn.sourceforge.net/stripes/?rev=1428&view=rev
Author: bengunter
Date: 2011-04-22 19:25:40 +0000 (Fri, 22 Apr 2011)
Log Message:
-----------
Fixed STS-817: Stack Overflow when using a layout with an existing component
name. LayoutComponentTag#isCurrentComponent() now checks not only the component
name but also the path to its parent render tag. This handles the case
presented in STS-817 where you have a component nested within a render nested
within a component of the same name (i.e.,
render/component[name="foo"]/render/component[name="foo"]).
Modified Paths:
--------------
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutContext.java
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java
2011-04-21 20:07:54 UTC (rev 1427)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutComponentTag.java
2011-04-22 19:25:40 UTC (rev 1428)
@@ -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:
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutContext.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutContext.java
2011-04-21 20:07:54 UTC (rev 1427)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/LayoutContext.java
2011-04-22 19:25:40 UTC (rev 1428)
@@ -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