Revision: 1460
http://stripes.svn.sourceforge.net/stripes/?rev=1460&view=rev
Author: bengunter
Date: 2012-02-06 15:49:04 +0000 (Mon, 06 Feb 2012)
Log Message:
-----------
Resurrected the original, buffered layout tags in a new
net.sourceforge.stripes.tag.layout.buffered package, along with a separate TLD
and URI, for use by people whose layouts and/or platform (WebLogic) are not
compatible with the new streaming layout tags.
Modified Paths:
--------------
branches/1.5.x/stripes/build.xml
branches/1.5.x/stripes/pom.xml
Added Paths:
-----------
branches/1.5.x/stripes/resources/stripes-buffered-layout.tld
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutComponentTag.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutContext.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutDefinitionTag.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutRenderTag.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/package.html
Modified: branches/1.5.x/stripes/build.xml
===================================================================
--- branches/1.5.x/stripes/build.xml 2011-12-02 21:13:16 UTC (rev 1459)
+++ branches/1.5.x/stripes/build.xml 2012-02-06 15:49:04 UTC (rev 1460)
@@ -88,6 +88,7 @@
<filter filtersfile="${tld.dir}/common-descriptions.properties"/>
<filter token="dynattrs" value="false"/>
<copy file="${tld.dir}/stripes.tld" todir="${classes.dir}/META-INF"
filtering="true"/>
+ <copy file="${tld.dir}/stripes-buffered-layout.tld"
todir="${classes.dir}/META-INF" filtering="true"/>
<filter token="dynattrs" value="true"/>
<copy file="${tld.dir}/stripes.tld"
tofile="${classes.dir}/META-INF/stripes-dynattr.tld" filtering="true"/>
Modified: branches/1.5.x/stripes/pom.xml
===================================================================
--- branches/1.5.x/stripes/pom.xml 2011-12-02 21:13:16 UTC (rev 1459)
+++ branches/1.5.x/stripes/pom.xml 2012-02-06 15:49:04 UTC (rev 1460)
@@ -44,8 +44,8 @@
<!-- make two copies of the taglib, one with
and one without dynamic attributes -->
<filter
filtersfile="./resources/common-descriptions.properties"/>
<filter token="dynattrs" value="false"/>
- <copy file="./resources/stripes.tld"
todir="./target/classes/META-INF"
- filtering="true"/>
+ <copy file="./resources/stripes.tld"
todir="./target/classes/META-INF" filtering="true"/>
+ <copy
file="./resources/stripes-buffered-layout.tld"
todir="./target/classes/META-INF" filtering="true"/>
<filter token="dynattrs" value="true"/>
<copy file="./resources/stripes.tld"
Added: branches/1.5.x/stripes/resources/stripes-buffered-layout.tld
===================================================================
--- branches/1.5.x/stripes/resources/stripes-buffered-layout.tld
(rev 0)
+++ branches/1.5.x/stripes/resources/stripes-buffered-layout.tld
2012-02-06 15:49:04 UTC (rev 1460)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Copyright 2005-2006 Tim Fennell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ version="2.0">
+
+ <description>
+ Provides tags for use with the Stripes presentation framework. There
are three main
+ groups of tags in this tag library. First come the HTML form tags.
These include
+ the form tag itself as well as tags for most of the input tag
variants. The second
+ is a set of tags for output error information, including 'errors',
'individual-error'
+ and others. Last is a set of utility tags. These include the
wizard-fields tag which
+ can write out hidden fields for values in the request, the
useActionBean tag to use
+ ActionBeans as view helpers and the link tags for generating links
similar to forms.
+ </description>
+ <display-name>Stripes Buffered Layout Tags for Backward
Compatibility</display-name>
+ <tlib-version>1.0</tlib-version>
+ <short-name>stripes-buffered-layout</short-name>
+ <uri>http://stripes.sourceforge.net/stripes-buffered-layout.tld</uri>
+
+ <!-- Layout Tags. -->
+ <tag>
+ <description><![CDATA[
+ <p>Defines a reusable layout. This tag is designed to wrap the
entire contents of a
+ JSP that is to be re-used to manage the layout of multiple pages.
It can contain
+ HTML, JSP content, scriptlets etc. It may also contain
stripes:layout-component
+ tags. The stripes:layout-component names a section of the layout
that can be
+ supplied during rendering (it may be empty, or have default
contents).</p>
+
+ <p>Layout definitions will also have access to, through
PageContext,
+ any attributes/parameters supplied at rendering time. These can
be referenced in the layout
+ definition using EL, for example as ${myCustomParameter}. This
allows layouts not
+ only to templatize look and feel, but to potentially render
differently based on
+ the values of parameters passed in at rendering time.</p>
+ ]]></description>
+ <name>layout-definition</name>
+
<tag-class>net.sourceforge.stripes.tag.layout.buffered.LayoutDefinitionTag</tag-class>
+ <body-content>JSP</body-content>
+ </tag>
+
+ <tag>
+ <description><![CDATA[
+ <p>Used to define or supply a component of a layout. The
stripes:layout-component
+ tag can be nested inside both the stripes:layout-definition and
+ stripes:layout-render tags. In the former case it defines a named
component in the
+ layout, and the (optional) body provides a default for the
component. When nested in
+ a stripes:layout-render tag, the body overrides the named
component defined in the
+ layout.</p>
+
+ <p>The vanilla case would be to have a layout which defines the
header/footer etc. for
+ your site and that has a component named "body" or "contents" or
something similar,
+ which wraps the area where page content would normally be
displayed. Then, when
+ using that layout through a stripes:layout-render tag, you would
use a
+ stripes:layout-component tag to provide a value for the "body" or
"contents"
+ component of the layout.</p>
+ ]]></description>
+ <name>layout-component</name>
+
<tag-class>net.sourceforge.stripes.tag.layout.buffered.LayoutComponentTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+ The name of the component being defined (in the layout
definition) or overridden
+ (when rendering the layout).
+ </description>
+ <name>name</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description><![CDATA[
+ <p>Renders the named layout, supplying it with any specified
parameters and overridden
+ components. In addition to being able to supply nested
stripes:layout-component tags,
+ you may also supply any number of dynamic or arbitrary parameters
to this tag. All
+ parameters (except name) will be made available to the layout
definition through the
+ page context.</p>
+ ]]></description>
+ <name>layout-render</name>
+
<tag-class>net.sourceforge.stripes.tag.layout.buffered.LayoutRenderTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+ The name of the layout. Since only JSP layouts are supported,
this should be the
+ web application relative path to the JSP that defines the
layout.
+ </description>
+ <name>name</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <dynamic-attributes>true</dynamic-attributes>
+ </tag>
+</taglib>
Added:
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutComponentTag.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutComponentTag.java
(rev 0)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutComponentTag.java
2012-02-06 15:49:04 UTC (rev 1460)
@@ -0,0 +1,117 @@
+/* Copyright 2005-2006 Tim Fennell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sourceforge.stripes.tag.layout.buffered;
+
+import net.sourceforge.stripes.tag.StripesTagSupport;
+import net.sourceforge.stripes.util.Log;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyTag;
+import javax.servlet.jsp.tagext.BodyContent;
+
+/**
+ * Defines a component in a layout. Used both to define the components in a
layout definition
+ * and to provide overridden component definitions during a layout rendering
request.
+ *
+ * @author Tim Fennell
+ * @since Stripes 1.1
+ */
+public class LayoutComponentTag extends StripesTagSupport implements BodyTag {
+ private static final Log log = Log.getInstance(LayoutComponentTag.class);
+ private String name;
+ private BodyContent bodyContent;
+ private LayoutDefinitionTag definitionTag;
+ private LayoutRenderTag renderTag;
+
+ /** Gets the name of the component. */
+ public String getName() { return name; }
+
+ /** Sets the name of the component. */
+ public void setName(String name) {
+ if (name != null && name.length() > 0) {
+ int length = name.length();
+ boolean validJava =
Character.isJavaIdentifierStart(name.charAt(0));
+ int index = 1;
+ while (validJava && index < length) {
+ validJava = Character.isJavaIdentifierPart(name.charAt(index));
+ index++;
+ }
+ if (!validJava) {
+ log.warn("The layout-component name '", name, "' is not a
valid Java identifier. ",
+ "While this may work, it can cause bugs that are difficult
to track down. Please ",
+ "consider using valid Java identifiers for component names
(no hyphens, no spaces, etc.)");
+ }
+ }
+ this.name = name;
+ }
+
+ /** Save the body content output by the tag. */
+ public void setBodyContent(BodyContent bodyContent) {
+ this.bodyContent = bodyContent;
+ }
+
+ /**
+ * Behaviour varies depending on whether the tag is nested inside a
LayoutRenderTag or a
+ * LayoutDefinitionTag. In the first case it will always render it's
output to a buffer so that
+ * it can be provided to the render tag. In the second case, checks to
see if the component
+ * has been overridden. If so, does nothing, else writes its content to
the output stream.
+ *
+ * @return EVAL_BODY_BUFFERED, EVAL_BODY_INCLUDE or SKIP_BODY as described
above.
+ */
+ @Override
+ public int doStartTag() throws JspException {
+ this.definitionTag = getParentTag(LayoutDefinitionTag.class);
+ this.renderTag = getParentTag(LayoutRenderTag.class);
+
+ if (this.renderTag != null) {
+ return EVAL_BODY_BUFFERED;
+ }
+ else if (this.definitionTag.permissionToRender(this.name)) {
+ return EVAL_BODY_INCLUDE;
+ }
+ else {
+ return SKIP_BODY;
+ }
+ }
+
+ /** Does nothing. */
+ public void doInitBody() throws JspException { /* Do Nothing */ }
+
+ /**
+ * Does nothing.
+ * @return SKIP_BODY in all cases.
+ */
+ public int doAfterBody() throws JspException { return SKIP_BODY; }
+
+ /**
+ * If the tag is nested in a LayoutRenderTag, provides the tag with the
generated contents.
+ * Otherwise, does nothing.
+ *
+ * @return EVAL_PAGE in all cases.
+ */
+ @Override
+ public int doEndTag() throws JspException {
+ if (this.renderTag != null && this.bodyContent != null) {
+ this.renderTag.addComponent(this.name,
this.bodyContent.getString());
+ }
+
+ // Clean up in case the tag gets pooled
+ this.definitionTag = null;
+ this.renderTag = null;
+
+
+ return EVAL_PAGE;
+ }
+}
Added:
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutContext.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutContext.java
(rev 0)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutContext.java
2012-02-06 15:49:04 UTC (rev 1460)
@@ -0,0 +1,60 @@
+/* Copyright 2005-2006 Tim Fennell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sourceforge.stripes.tag.layout.buffered;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Used to move contextual information about a layout rendering between a
LayoutRenderTag and
+ * a LayoutDefinitionTag. Holds the set of overridden components and any
parameters provided
+ * to the render tag.
+ *
+ * @author Tim Fennell
+ * @since Stripes 1.1
+ */
+public class LayoutContext {
+ private Map<String,String> components = new HashMap<String,String>();
+ private Map<String,Object> parameters = new HashMap<String,Object>();
+ private boolean rendered = false;
+
+ /**
+ * Gets the Map of overridden components. Will return an empty Map if no
components were
+ * overridden.
+ */
+ public Map<String, String> getComponents() {
+ return components;
+ }
+
+ /** Gets the Map of parameters. Will return an empty Map if none were
provided. */
+ public Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ /** Returns true if the layout has been rendered, false otherwise. */
+ public boolean isRendered() { return rendered; }
+
+ /** False initially, should be set to true when the layout is actually
rendered. */
+ public void setRendered(final boolean rendered) { this.rendered =
rendered; }
+
+ /** To String implementation the parameters, and the component names. */
+ @Override
+ public String toString() {
+ return "LayoutContext{" +
+ "component names=" + components.keySet() +
+ ", parameters=" + parameters +
+ '}';
+ }
+}
Added:
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutDefinitionTag.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutDefinitionTag.java
(rev 0)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutDefinitionTag.java
2012-02-06 15:49:04 UTC (rev 1460)
@@ -0,0 +1,123 @@
+/* Copyright 2005-2006 Tim Fennell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sourceforge.stripes.tag.layout.buffered;
+
+import net.sourceforge.stripes.tag.StripesTagSupport;
+import net.sourceforge.stripes.util.Log;
+
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+import java.util.Stack;
+import java.util.Map;
+
+/**
+ * On the surface, allows a developer to define a layout using a custom tag -
but is actually
+ * the tag responsible for generating the output of the layout. A layout can
have zero or more
+ * nested components, as well as regular text and other custom tags nested
within it.
+ *
+ * @author Tim Fennell
+ * @since Stripes 1.1
+ */
+public class LayoutDefinitionTag extends StripesTagSupport {
+ private static final Log log = Log.getInstance(LayoutDefinitionTag.class);
+
+ /**
+ * Prefix used to construct the request attribute name used to pass
context from the
+ * LayoutRenderTag to the LayoutDefinitionTag.
+ */
+ public static final String PREFIX = "stripes.layout.";
+
+ private LayoutContext context;
+
+ /**
+ * Looks up the layout context that has been setup by a LayoutRenderTag.
Uses the context
+ * to push any dynamic attributes supplied to the render tag in to the
page context
+ * available during the body of the LayoutDefinitionTag.
+ *
+ * @return EVAL_BODY_INCLUDE in all cases.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public int doStartTag() throws JspException {
+ // Since the layout-render tag pushes a new writer onto the stack, we
can clear the
+ // buffer here to make sure we don't output anything outside the
layout-def tag.
+ try {
+ getPageContext().getOut().clearBuffer();
+ }
+ catch (IOException ioe) {
+ // Not a whole lot we can do if we cannot clear the buffer :/
+ log.warn("Could not clear buffer before rendering a layout.", ioe);
+ }
+
+ // Assuming that the layout definition page is always included, the
following line gets
+ // the name of the page the tag is sitting on, as per Servlet 2.4
spec, page 65.
+ String name = (String) getPageContext().getRequest()
+ .getAttribute("javax.servlet.include.servlet_path");
+
+ // Fetch the layout context containing parameters and component
overrides
+ Stack<LayoutContext> stack = (Stack<LayoutContext>)
+ getPageContext().getRequest().getAttribute(PREFIX + name);
+ this.context = stack.peek();
+
+ // Put any additional parameters into page context for the definition
to use
+ for (Map.Entry<String,Object> entry :
this.context.getParameters().entrySet()) {
+ getPageContext().setAttribute(entry.getKey(), entry.getValue());
+ }
+
+ for (Map.Entry<String,String> entry :
this.context.getComponents().entrySet()) {
+ getPageContext().setAttribute(entry.getKey(), entry.getValue());
+ }
+
+ // Technically we're not quite done yet, but this flag is only used to
+ // indicate that an attempt was made to render
+ this.context.setRendered(true);
+
+ return EVAL_BODY_INCLUDE;
+ }
+
+ /**
+ * Causes page evaluation to end once the end of the layout definition is
reached.
+ * @return SKIP_PAGE in all cases
+ */
+ @Override
+ public int doEndTag() throws JspException {
+ return SKIP_PAGE;
+ }
+
+ /**
+ * Called by nested tags to find out if they have permission to render
their content, or
+ * if they have been overridden in the layout rendering tag. Returns true
if a component
+ * has not been overridden and should render as normal. Returns false,
and writes out the
+ * overridden component when the component has been overridden.
+ *
+ * @param componentName the name of the component about to render
+ * @return true if the component should render itself, false otherwise
+ * @throws JspException if the JspWriter could not be written to
+ */
+ public boolean permissionToRender(String componentName) throws
JspException {
+ if (this.context.getComponents().containsKey(componentName)) {
+ try {
+
getPageContext().getOut().write(this.context.getComponents().get(componentName));
+ }
+ catch (IOException ioe) {
+ throw new JspException("Could not output overridden layout
component.", ioe);
+ }
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+}
Added:
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutRenderTag.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutRenderTag.java
(rev 0)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/LayoutRenderTag.java
2012-02-06 15:49:04 UTC (rev 1460)
@@ -0,0 +1,150 @@
+/* Copyright 2005-2006 Tim Fennell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sourceforge.stripes.tag.layout.buffered;
+
+import net.sourceforge.stripes.exception.StripesJspException;
+import net.sourceforge.stripes.tag.StripesTagSupport;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyContent;
+import javax.servlet.jsp.tagext.BodyTag;
+import javax.servlet.jsp.tagext.DynamicAttributes;
+import java.util.Stack;
+
+/**
+ * Renders a named layout, optionally overriding one or more components in the
layout. Any
+ * attributes provided to the class other than 'name' will be placed into page
context during
+ * the evaluation of the layout, making them available to other tags, and in
EL.
+ *
+ * @author Tim Fennell
+ * @since Stripes 1.1
+ */
+public class LayoutRenderTag extends StripesTagSupport implements BodyTag,
DynamicAttributes {
+ private String name;
+ private LayoutContext context = new LayoutContext();
+
+ /** Gets the name of the layout to be used. */
+ public String getName() { return name; }
+
+ /** Sets the name of the layout to be used. */
+ public void setName(String name) { this.name = name; }
+
+ /** Used by the JSP container to provide the tag with dynamic attributes.
*/
+ public void setDynamicAttribute(String uri, String localName, Object
value) throws JspException {
+ this.context.getParameters().put(localName, value);
+ }
+
+ /**
+ * Allows nested tags to register their contents for rendering in the
layout.
+ *
+ * @param name the name of the component to be overridden in the layout
+ * @param contents the output that will be used
+ */
+ public void addComponent(String name, String contents) {
+ this.context.getComponents().put(name, contents);
+ }
+
+ /**
+ * Pushes the values of any dynamic attributes into page context
attributes for
+ * the duration of the tag.
+ *
+ * @return EVAL_BODY_BUFFERED in all cases
+ */
+ @Override
+ public int doStartTag() throws JspException {
+ pushPageContextAttributes(this.context.getParameters());
+ return EVAL_BODY_BUFFERED;
+ }
+
+ /**
+ * Discards the body content since it is not used. Input from nested
LayoutComponent tags is
+ * captured through a different mechanism.
+ */
+ public void setBodyContent(BodyContent bodyContent) { /* Don't use it */ }
+
+ /** Does nothing. */
+ public void doInitBody() throws JspException { /* Do nothing. */ }
+
+ /**
+ * Does nothing.
+ * @return SKIP_BODY in all cases.
+ */
+ public int doAfterBody() throws JspException { return SKIP_BODY; }
+
+ /**
+ * Invokes the named layout, providing it with the overridden components
and provided
+ * parameters.
+ * @return EVAL_PAGE in all cases.
+ * @throws JspException if any exceptions are encountered processing the
request
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public int doEndTag() throws JspException {
+ try {
+ if (!name.startsWith("/")) {
+ throw new StripesJspException("The name= attribute of the
layout-render tag must be " +
+ "an absolute path, starting with a forward slash (/).
Please modify the " +
+ "layout-render tag with the name '" + name + "'
accordingly.");
+ }
+
+ HttpServletRequest request = (HttpServletRequest)
getPageContext().getRequest();
+
+ // Put the components into the request, for the definition tag to
use.. using a stack
+ // to allow for the same layout to be nested inside itself :o
+ String attributeName = LayoutDefinitionTag.PREFIX + this.name;
+ Stack<LayoutContext> stack =
+ (Stack<LayoutContext>) request.getAttribute(attributeName);
+ if (stack == null) {
+ stack = new Stack<LayoutContext>();
+ request.setAttribute(attributeName, stack);
+ }
+
+ stack.push(this.context);
+
+ // Now wrap the JSPWriter, and include the target JSP
+ BodyContent content = getPageContext().pushBody();
+ getPageContext().include(this.name, false);
+ getPageContext().popBody();
+ getPageContext().getOut().write(content.getString());
+
+ // Check that the layout actually got rendered as some containers
will
+ // just quietly ignore includes of non-existent pages!
+ if (!this.context.isRendered()) {
+ throw new StripesJspException(
+ "Attempt made to render a layout that does not exist. The
layout name " +
+ "provided was '" + this.name + "'. Please check that a
JSP/view exists at " +
+ "that location within your web application."
+ );
+ }
+
+
+ stack.pop();
+ popPageContextAttributes(); // remove any dynattrs from page scope
+
+ // Clean up in case the tag gets pooled
+ this.context = new LayoutContext();
+ }
+ catch (StripesJspException sje) { throw sje; }
+ catch (Exception e) {
+ throw new StripesJspException(
+ "An exception was raised while invoking a layout. The layout
used was " +
+ "'" + this.name + "'. The following information was supplied
to the render " +
+ "tag: " + this.context.toString(), e);
+ }
+
+ return EVAL_PAGE;
+ }
+}
Added:
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/package.html
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/package.html
(rev 0)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/layout/buffered/package.html
2012-02-06 15:49:04 UTC (rev 1460)
@@ -0,0 +1,6 @@
+<body>
+ <p>This package contains the old, buffered layout tags that were present
+ in Stripes releases up to and including 1.5.3. Some incompatibilities
+ between the two implementations remain unresolved so these buffered tags
+ are made available under a different URI.</p>
+</body>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development