This came up here briefly not too long ago, but I don't think it was
settled to any degree. Scott Snyder asked about generating "id"
attributes for <input> tags generated by the Struts taglib, I believe
for the purpose of using stylesheets. I have another reason for wanting
the id attribute: <label> tags. The fields to which they refer must have
an id defined; it doesn't work on the name attribute.

I understand that there is a bit of a difficulty in simply reusing the
property/name value for the id, as this would cause problems if a page
included two forms with any identically named fields (or the id was used
anywhere else outside the forms). So perhaps the Struts-generated IDs
could be a dot-notation name based on the form and field names (e.g.
loginForm.userName). Unfortunately, this might not be ideal for the
stylesheet user who wants to format every field with a particular name
in a certain way, but one could still use classes to achieve the desired
result (though slightly less conveniently).

The other issue would be what to use for the form name. The simplest
answer is to use the existing name (either specified or, more typically,
obtained by looking up the specified action in the action mapping), but
then you're forced to repeat the form name in the JSP file when it might
previously have been specified only in the struts-config.xml file
(making it easier to change). However, if an <html:label> tag was added
(or labels could be incorporated into the existing custom tags), the
need to specify the form name in the JSP would be largely eliminated.
Otherwise, one might want the ability to add a page-local name in the
<html:form> tag.

Any thoughts on this?

--
Michael Hackett
Developer, Pictorius Inc.

Reply via email to