Author: pbenedict
Date: Tue Jun 26 22:59:05 2007
New Revision: 551063
URL: http://svn.apache.org/viewvc?view=rev&rev=551063
Log:
STR-1175: Add scope
Modified:
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/XhtmlTag.java
struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld
Modified:
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java
URL:
http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java?view=diff&rev=551063&r1=551062&r2=551063
==============================================================================
---
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java
(original)
+++
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java
Tue Jun 26 22:59:05 2007
@@ -797,11 +797,14 @@
* Returns true if the custom tags are in XHTML mode.
*/
public boolean isXhtml(PageContext pageContext) {
- String xhtml =
- (String) pageContext.getAttribute(Globals.XHTML_KEY,
- PageContext.PAGE_SCOPE);
-
- return "true".equalsIgnoreCase(xhtml);
+ String xhtml;
+ try {
+ xhtml = (String) lookup(pageContext, Globals.XHTML_KEY, null);
+ return "true".equalsIgnoreCase(xhtml);
+ } catch (JspException e) {
+ log.error("Failed xhtml lookup", e);
+ throw new RuntimeException(e);
+ }
}
/**
Modified:
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/XhtmlTag.java
URL:
http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/XhtmlTag.java?view=diff&rev=551063&r1=551062&r2=551063
==============================================================================
---
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/XhtmlTag.java
(original)
+++
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/XhtmlTag.java
Tue Jun 26 22:59:05 2007
@@ -20,7 +20,10 @@
*/
package org.apache.struts.taglib.html;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.struts.Globals;
+import org.apache.struts.taglib.TagUtils;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
@@ -32,6 +35,17 @@
* Example:<br/> <html:xhtml/> </p>
*/
public class XhtmlTag extends TagSupport {
+
+ /**
+ * Commons logging instance.
+ */
+ private static final Log log = LogFactory.getLog(XhtmlTag.class);
+
+ /**
+ * The scope within which to store the markup format.
+ */
+ private String scope;
+
/**
* Constructor for XhtmlTag.
*/
@@ -43,9 +57,24 @@
* @see javax.servlet.jsp.tagext.Tag#doEndTag()
*/
public int doEndTag() throws JspException {
- this.pageContext.setAttribute(Globals.XHTML_KEY, "true",
- PageContext.PAGE_SCOPE);
-
+ int inScope = PageContext.PAGE_SCOPE;
+ try {
+ if (scope != null) {
+ inScope = TagUtils.getInstance().getScope(scope);
+ }
+ } catch (JspException e) {
+ log.warn("invalid scope name - defaulting to PAGE_SCOPE", e);
+ }
+
+ this.pageContext.setAttribute(Globals.XHTML_KEY, "true", inScope);
return EVAL_PAGE;
+ }
+
+ public String getScope() {
+ return this.scope;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
}
}
Modified:
struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld
URL:
http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld?view=diff&rev=551063&r1=551062&r2=551063
==============================================================================
--- struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld
(original)
+++ struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld
Tue Jun 26 22:59:05 2007
@@ -9565,16 +9565,28 @@
Using this tag in a page tells all other html taglib tags
to render themselves as XHTML 1.0. This is useful
when composing pages with JSP includes or Tiles.
- <html:html xhtml="true"> has a similar effect. This
- tag has no attributes; you use it like this: <html:xhtml/>.
+ <html:html xhtml="true"> has a similar effect.
</p>
<p>
<strong>Note</strong>: Included pages do not inherit the rendering
- style of the including page. Each JSP fragment or Tile must use
this
- tag to render as XHTML.
+ style of the including page by default. Without setting the
+ <code>scope</code> attribute, which defaults to <code>page</code>
+ scope, each JSP fragment or Tile must use this tag to render as
+ XHTML.
</p>
]]>
</description>
+ <attribute>
+ <name>scope</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ <![CDATA[
+ <p>Specifies the variable scope searched to retrieve the rendering
+ setting. If not specified, the default is page scope.</p>
+ ]]>
+ </description>
+ </attribute>
</tag>
</taglib>