struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heikki Hyyrö <heikki.hy...@uta.fi>
Subject Re: Struts 2 and automatic ids
Date Thu, 11 Sep 2014 13:15:41 GMT
Martin Gainty <mgainty@hotmail.com> kirjoitti 11.9.2014 kello 14.31:
> 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:

Yes, I am quite aware of what ids are used for. But the idea of generating ids without any
real need for them is strange. For example one page has a large form with dozens of links.
Struts generates unique (and rather long, creating unnecessary bloating) ids to each different
link. For example one page with (possibly hundreds of) links to modifying user information
has an id of form ”updateUserGroups_#” for each such link (where # is a number representing
the particular user whose information the link allows to edit).

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

Yes, this is something I have been trying to look into, but before trying to create a new
template I was wondering if there is no simpler way.

> 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?

Like mentioned, one goal for me is to have the pages pass the W3C markup validator without
errors. Currently Struts sometimes gives identical ids to more than one element on the same
page. Of course one might say that failing validation is not a big deal in itself, but still
it feels a bit ”dodgy”…

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

Thank you for this reference, I have tried to look for existing discussion about the topic
but had not found this! It seems that this reference discusses exactly what I would like to
do. And unfortunately it also seems (based on the reference) that there is no easy way out,
as they mention that some parts in the Struts Java code itself assume existence of ids.

Perhaps the simplest way is to replace all <s:form> tags by basic <form> tags,
as the id-bloating seems to happen mainly within forms. This leads to a bit more complicated
form markup in the jsp files, but overall should not be a too big nuisance.

-Heikki
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message