struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject RE: Struts 2 and automatic ids
Date Thu, 11 Sep 2014 11:31:19 GMT


> From:
> Subject: Struts 2 and automatic ids
> Date: Thu, 11 Sep 2014 02:13:44 +0300
> To:
> Hi all,
> I recently began to audit a Struts application that I am maintaining. While
running the pages through the HTML markup validation test at, 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
> 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

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" />

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


 Best regards,
> Heikki
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message