Andrew,
Hi. I just posted to the list some adjustments to the struts tags to do exactly
this. (see "Re: How can I pass extra information on Submit button?" - or see "
Proposal to add "indexed" to tags for Grid/Matrix-type use of Struts")
In your case, you would just add 'indexed="true"' to your text field, and it
will generate the name "searchField[x].id" where x is the index of your
collection. Have been using it a lot myself, and very pleased with the result.
When I get a minute (got a big presentation today!) I will post the code to the
struts-dev list and hopefully have it added to the Struts source.
Cheers,
Dave
PS Attaching latest zip which now includes the LINK tag which can be indexed.
In this case, an extra parameter is added to the query string "...index=x" where
x is index of collection.
(See attached file: struts indexed files.ZIP)
Andrew Paul Swift <[EMAIL PROTECTED]> on
06/26/2001 06:24:55 AM
Please respond to [EMAIL PROTECTED]
To: "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]>
cc: (bcc: David Hay/Lex/Lexmark)
Subject: Form problem
I have an array beans which I am trying to use to build up a dynamic form.
The bean has 3 properties DisplayName, id and value.
The id property is the unique identifier that corresponds to the name of the
HTML input field.
The value property contains the value of the HTML text field.
The displayName property contains the name that should be displayed next to
the form field.
so... I iterate through the array and build up the form
<logic:iterate id="searchField" type="package.SearchField"
name="<%=Constants.SEARCH_FIELD_KEY %>">
<tr>
<td><bean:write name="searchField"property="displayName"
/></td>
<td><html:text name="searchField"property="id" /></td>
</tr>
</logic:iterate>
which produces this output ...
<tr>
<td>FORNAVN</td>
<td><input type="text" name="id" value="FIRSTNAME"></td>
</tr>
<tr>
<td>LASTNAME</td>
<td><input type="text" name="id" value="LASTNAME"></td>
</tr>
but... the HTML name attribute is always "id" which means that I can't
identify the individual fields.
I want the name attribute of the HTML input field to be the value stored in
beans id property!
n.b. I have no control over what the search fields may be. I just have to
handle whatever I get.
Any ideas??
cheers
Andrew
---------------------------------------------------------------------
To send us encrypted mail, please refer to:
http://www.millionhandshakes.com/emailpolicy/pgp.html
Million Handshakes
.ZIP File