You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Keith Winkler <ke...@gmail.com> on 2008/02/07 07:45:23 UTC

html:form generates invalid xhml

It seems possible that STR-2232 and STR-2033, which are marked as
resolved/fixed, are not really fixed.

https://issues.apache.org/struts/browse/STR-2232
https://issues.apache.org/struts/browse/STR-2033


In struts 1.3.8 (and presumably 1.3.9 beta)

 <html:html xhtml="true">
 <html:form action="/itemsEdit" focus="item.description">


Will generate:


<script type="text/javascript">
 var focusControl = document.forms["itemEditForm"].elements["item.description"];

 if (focusControl.type != "hidden" && !focusControl.disabled &&
focusControl.style.display != "none") {
 focusControl.focus();
 }
</script>



Which is not really valid xhtml on account of the un-escaped "&" characters.

Here is a link to the relevant portion of the xhtml specification:

http://www.w3.org/TR/xhtml1/#h-4.8

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


Re: [struts-dev] html:form generates invalid xhml

Posted by Keith Winkler <ke...@gmail.com>.
>
> <script type="text/javascript">
> //<![CDATA[
> code goes here.
> //]]>
> </script>
>
> Maybe this solution can be used to ensure xhtml conformance?
>
>

Right.  That was the solution arrived at in the bug report discussion I
referenced.  But the patch seems to have never made it into the software.
Since the <html:form> tag generates the javascript, struts must create the
CDATA section, or use XML character entity references: &amp;&amp;, etc.

Keith

Re: [struts-dev] html:form generates invalid xhml

Posted by Dale Newfield <Da...@Newfield.org>.
Keith Winkler wrote:
> Which is not really valid xhtml on account of the un-escaped "&" characters.

The standard solution for this is wrapping your js code with the 
following javascript comments/xml CDATA declaration:

<script type="text/javascript">
//<![CDATA[
code goes here.
//]]>
</script>

Maybe this solution can be used to ensure xhtml conformance?

-Dale

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