struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Husted" <>
Subject Re: [Struts 2] <s:form> and <s:textfield> tags adding unwanted HTML code
Date Fri, 15 Sep 2006 10:08:48 GMT
Yes, if you prefer to code your own markup, then you can use the
simple theme. To use the simple theme throughout an application, add
this line to the file.

* struts.ui.theme=simple

The file can be placed under classes, next to the
struts.xml file.

The themes are designed to reduce the amount of markup we need to code
into each page. The general idea is that we can create a form just by
specifying the fields, and let the theme generate the HTML markup for
us. (Like using an advanced stylesheet.) The default theme has handy
features like automatically displaying validation errors above each
field, with any extra work on our part.

Here's the source code for the example, relying on the theme to
generate the HTML markup.

> <s:form action="userConnect">
>   <s:textfield label="Connectez vous:"  name="login"  size="20" />
>   <s:password label="mot de passe : " name="password" id="password" size="20" />
>   <s:submit type="image" id="imgSubmit" src="www/tortue_contour_noire_20_16.jpg" />
>   </s:form>

Note that the Struts 2 tags include new attributes, like "label". The
XHTML (and AJAX) themes will automatically inject a label tag into the

Of course, you can always use the simple theme and inject all the
markup by hand, as we do in Struts 1.

The themes and individual tags can also be extended, if need be, to
meet any specific needs of an application.


-- HTH, Ted.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message