I used the following code for two text boxes, u can change it to your
need
I am also learning so bear with my suggestions.
1. Action form code:
private ArrayList personList;
public void reset(ActionMapping mapping, HttpServletRequest request){
this.personList = new ArrayList();
// String num = request.getParameter("personListLength");
String num ="5";
try {
if (num != null) {
int len = Integer.parseInt(num);
for (int i = 0; i < len; i++)
this.personList.add(new PersonBean());
}
}catch (NumberFormatException e) {
e.printStackTrace();
}
}
public PersonBean getPerson(int ndx) {
return (PersonBean) personList.get(ndx);
}
public void setPersonList(int ndx, PersonBean p) {
personList.set(ndx, p);
}
public ArrayList getPersonList(){
return this.personList;
}
2. jsp
<TABLE id="mytable">
<logic:present name="personList">
<logic:iterate id="person" name="dynaTableForm" property="personList"
type="com.learning.struts.PersonBean" >
<tr>
<td>
<html:text name="person" property="firstName" indexed="true"/>
</td>
<td>
<html:text name="person" property="phoneNo" indexed="true"/>
</td>
</tr>
</logic:iterate>
</logic:present>
</TABLE>
3.PersonBean:
public class PersonBean implements Serializable
{
String firstName;
String phoneNo;
public PersonBean()
{
super();
}
public String getFirstName()
{
return firstName;
}
public void setFirstName(String newFirstName)
{
firstName = newFirstName;
}
public String getPhoneNo()
{
return phoneNo;
}
public void setPhoneNo(String newPhoneNo)
{
phoneNo = newPhoneNo;
}
}
Let me know if u need any further info.
Thanks
>>> [EMAIL PROTECTED] 06/12/03 01:35PM >>>
Hi,
I am not able to pass more than one value when a multibox is checked. Is
there any
possible (or alternate) way to do it?
I have a table in the JSP where each row contains a multibox, and a
text field. When I select a checkbox and then enter some value in the
text field and Submit, I need to get text field value related to this
checkbox. Is there a possible way to achieve this?
How can I know which checkbox connects to which text field?
My jsp page is as followings:
<logic:iterate id="element" name="projects" >
<tr>
<td align="right">
<html:multibox property="selectedItems" >
<bean:write name="element" property="id"/>
</html:multibox>
</td>
<td align="right"><strong>project Title:</strong></td>
<td><html:text name="element" property="name"/>
</td>
</tr>
</logic:iterate>
Thanks in advance!
Sarah