struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Deadman, Hal" <hal.dead...@tallan.com>
Subject RE: Converting struts-html tags to be XHTML-compliant
Date Mon, 12 Nov 2001 22:15:12 GMT
I would think request scope would be better than pageContext so the
attribute will be available inside jsp:include or template/component
includes.

-----Original Message-----
From: Matt Raible [mailto:matt@raibledesigns.com]
Sent: Monday, November 12, 2001 12:01 AM
To: struts-dev@jakarta.apache.org
Subject: Converting struts-html tags to be XHTML-compliant


I am taking on the project of converting (with backwards compatibility) all
the struts-html tags to be XHTML-compliant.

I'd like to use this e-mail to tell you my approach, ask you for advice, and
get your feedback.

1.  Approach:

	In HtmlTag.java, add
		if (xhtml)
			pageContext.setAttribute("xhtml", "true");

	In all other html-producing tags (i.e. img, input), do a check when closing
the tag:

			// check if this is an XHTML document
	                String xhtml = (String) pageContext.getAttribute("xhtml");

	                if (xhtml != null && xhtml.equals("true")) {
	                    results.append("\" />"); // extra space before close
will allow XHTML to work in older browsers
	                } else {
	                    results.append("\">");
	                }

2.  Advice:

Should I be setting the "xhtml" variable in the pageContext, request, or
session.  Page seems to make the most sense since that is what this variable
relates to.  However, to do this (to my understanding), I have to create
HtmlTei.java and add the <teiclass> declaration to the struts-html.tld:

	public class HtmlTei extends TagExtraInfo {

	    /**
	     * Return information about the scripting variables to be created.
	     */
		    public VariableInfo[] getVariableInfo(TagData data) {

			return new VariableInfo[] {
			  new VariableInfo(data.getAttributeString("xhtml"),
			                   "java.lang.String",
			                   true,
			                   VariableInfo.NESTED)
			};

		    }

	}

However, this does not work as I'd expect it to.  What I'm expecting is that
I am exposing the "xhtml" variable simply by adding the HtmlTei class - but
it's not working at all.

3.  Feedback:

Please let me know what you think of this approach.  By doing this, and
adding a check if the user wants the doc to be XHTML, we should achieve full
backwards compatibility, and be able to convert the struts-html tags to be
XHTML-compliant.

Thanks,

Matt





--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message