Reputation: 78116
I use struts-html to generate forms fields.
For example:
<%@ taglib prefix="html" uri="/WEB-INF/taglibs/struts-html.tld" %>
<html:text property="email" styleId="email" size="44"/>
generates:
<input type="text" name="email" size="44" value="" id="email">
As shown above the generated input tag is not closed. This causes my html to be not valid.
struts-html.tld includes:
<tlibversion>1.2</tlibversion>
<jspversion>1.1</jspversion>
<shortname>html</shortname>
<uri>http://struts.apache.org/tags-html</uri>
Does anyone knows why is the generated input not closed? Is there a newer version? Where can it be downloaded?
I tried using:
<html:html xhtml="true">
which renders as:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
However, my input tags keep rendering unclosed.
Solution:
Use the tag:
<html:xhtml/>
Note: If you use Tiles, as I do, use it directly inside your included jsp. It is not inherited from your base template file.
Note: Within xhtml mode you can not use sytleId inside a html:form tag. It is not a problem since the id property is automatically generated to store your bean's name.
Upvotes: 3
Views: 7798
Reputation: 64632
There must be a backing Java code that does the actual generation. Grab the source of the library since it's already open sourced and check if the code consults some parameters when it appends the closing tag bracket '>'. If it doesn't do that at all you may modify the library, use the patched version and contribute the patch.
Upvotes: 0
Reputation:
Can you not just use <html:xhtml/>
?
Using this tag in a page tells all other html taglib tags to render themselves as XHTML 1.0
Alternatively you could use <html:html xhtml="true">
.
Upvotes: 6
Reputation: 71979
input
tags don't have to be closed in HTML, so I'm guessing Struts doesn't know you're trying to generate XHTML. Sadly, my Struts-fu is so ancient I have no idea how to go about fixing it. Maybe you should fall back to HTML instead of XHTML; XHTML really only comes into its own when you're using other namespaces, such as SVG or MathML.
Upvotes: 0