I am working on Struts 1.1 framework.
In JSP Page, I am using a <html:select property="something">
tag.
My doubt:
In javascript we generally apply some properties to an element by using its id attribute as an identifier.
for eg.
html = <p id="x"></p>
javascript = document.getElementById['x'].style.display = "block";
I was doing reverse engineering of this code and since my application is very vast, due to some reasons I am not able to clearly find out if its true whether we can use the property attribute of the struts tags in place of id while identifying it.
for eg.
struts tag = <html:select property="abc"></html:select>
javascript = document.getElementById['abc'].style.display = "block";
(Note that I know we can use the styleId
attribute in struts tags to define an id. I am only trying to find out if its possible this way)
Take a look at the html rendered from one of these pages, and you'll find that for inputs the
property
in a struts tag becomesname
in the rendered html tag.If you want to add the
id
attribute to an html tag rendered from a struts tag, try adding thestyleId
attribute in the struts tag. For example:renders out to:
Note that
styleId
can be the same asproperty
. You can also get elements by name instead of id in javascript, but since id is supposed to be unique and name isn't, you'll have to deal with an array of elements.