> From: heikki.hy...@uta.fi
> Subject: Struts 2 and automatic ids
> Date: Thu, 11 Sep 2014 02:13:44 +0300
> To: user@struts.apache.org
> 
> Hi all,
> 
> I recently began to audit a Struts 2.3.16.1 application that I am 
> maintaining. While running the pages through the HTML markup validation test 
> at http://validator.w3.org/, I noticed a problem: Struts 2 seems to 
> automatically generate id’s to many elements related to forms, and sometimes 
> this results in a page that has several elements with identical auto 
> generated id. This then leads to a markup validation error. So far the only 
> way I have found to get around this is to explicitly generate own unique ids, 
> but this feels like a stupid solution. Is it not possible to prevent Struts 
> from auto generating ids to forms and some elements within them?
> 
> I have tried to google for some solution but have found nothing useful. In 
> case it matters, the application in question uses the basic Struts ”simple 
> theme” globally, but the same problem occurs also with the "xhtml theme".

MG>reference for id is here
http://www.w3.org/TR/html401/struct/global.html#adef-id

MG>the 'functions' the (generated) id plays are illustrated here:
The (unique) 
id attribute has several functions in HTML:


As a style sheet selector.As a target anchor for hypertext
links.As a means to reference a particular element from a script.As the name of 
a declared OBJECT element.For general purpose processing by user agents (e.g. 
for identifying fields
when extracting data from HTML pages into a database, translating HTML
documents into other formats, etc.).     
MG>struts generates HTML tags using themes which means you *can* create a 
custom theme as seen here
<constant name="struts.ui.theme" value="mkyong" />
http://www.mkyong.com/struts2/working-with-struts-2-theme-template/

MG>If you *dont* want to create a new custom theme you can refactor existing 
xhtml.ftl to set id=""
MG>can you indicate why you want to disable Struts generation of id for HTML 
tag?
MG>if set id="" then you would disable references to 'id' so the id reference 
would not resolve?

MG>http://struts.1045723.n5.nabble.com/Struts-tags-ID-generation-td3476228.html

 Best regards,
> 
> Heikki
MG>Martin
                                          

Reply via email to