From: "David_Hay/Lex/Lexmark.LEXMARK"@sweeper.lex.lexmark.com
Subject: "indexed" to tags
Hi everyone.
I have now finished updating several html Struts tags to produce indexed names
such as
<input type="text" name="parameter[0].value" value="Mac">
when used within an iterate tag. These tags involve only minor changes to the
existing tags, and to trigger them, "indexed=true" is added to the tag.
I changed BaseHandlerTag to include the "indexed" parameter with appropriate
setter & getters, and modified BaseFieldTag to change name if the indexed
parameter is specified. This automatically provides this capability to those
tags which extend BaseFieldTag, ie FileTag, HiddenTag, PasswordTag and TextTag.
For those that do not inherit from BaseFieldTag, I changed the tag code in
ButtonTag and CheckBox tag. I am willing to change any others that peope use
within an iterate tag and require the above indexed names.
Instructions for use:
- unpack attached zip file (this mailing list only accepts messages < 100K!!)
and copy .java files to ../org/apache/struts/taglib/html/
- rebuild struts
- add the struts-html.tld to your WEB-INF directory
- within an iterate tag, simply add "indexed=true" to the tag you wish to use.
Eg to produce the text tag
<input type="text" name="parameter[0].value" value="Mac">
use:
<logic:iterate id="parameter" name="ParametersForm"
property="parameterList">
...
<html:text name="parameter" property="value" indexed="true"/>
...
</logic:iterate>
This presumes form bean called ParametersForm, with a getParameterList()
method which returns a collection of parameters, a getParameter(int index)
method which returns a particular parameter in the collection, and each
parameter object has a getValue() method.
- (I used the index in the name for javascript validation etc in each row)
Hope this helps. Would really appreciate feedback from people. Also, believe
it would be a clean enhancement to current tags - what do I need to do to
propose the change?
Dave