You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steven <st...@steven.com.hk> on 2001/12/21 05:33:33 UTC
How to use SELECT tag inside iterate tag for String array
Hi,
I want to create a table of html <select> elements, and I have a Form
bean which has a 2D String array and a 1D String array:
String[][] optionSelected;
String[] options;
I think the code in the jsp should be something like this:
<logic:iterate id="row" name="selectOptionsForm" property="optionSelected">
<tr>
<logic:iterate name="col" name="row">
<td>
<html:select name="col" property="???" indexed="true">
<html:options property="options" />
</html:select>
</td>
</logic:iterate>
</tr>
</logic:iterate>
But what values should I assign to the "property" of the SELECT tag??
Alternatively, I've also tried not to use the iterate tag:
<html:select property='<%="optionSelected[" + i + "][" + j + "]"%>'>
<html:options property="options" />
</html:select>
and the generated html looks like this:
<select name="optionSelected[0][0]">
<option value="A">A
<option value="B">B
....
</select>
however, when I click the "Submit" button, I got the
"ArrayIndexOutOfBoundsExcepion" error!
How should I write the iterate and select tags, and the setter and
getter methods of the Form bean so that the values in "optionSelected"
are correctly retrieved and set after submission?
Thanks a lot for your help!!!
Steven
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>