In my JSP page I've displayed list of people with id
, name
and email
fields as follows:
<s:iterator value="peopleList">
<tr>
<td><input type="checkbox" name="checkedId" value="<s:property value="id"/>" /></td>
<td><s:property value="id"/></td>
<td><s:property value="firstName"/></td>
<td><s:property value="lastName"/></td>
<td><s:property value="email"/></td>
</tr>
</s:iterator>
My action class is as follows:
private String[] checkedId;
private List<People> peopleList;
PeopleDao peopleDao = new PeopleDaoImpl();
People people = new People();
private List<People> checkBoxList = new ArrayList<People>();
public String checkBox(){
System.out.println("Hello");
for(String p: checkedId){
System.out.println(p);
}
return SUCCESS;
}
Currently I'm sending an id
as check-box value and printing them out in action class. This works fine but what I want is to send the whole checked row of id
, name
s and email as an object of type People
as check-box value to store it in checkBoxList
. How do I achieve this?
I tried adding var="list"
in the iterator and using the "list" as the value for check-box with name="checkBoxList"
but it didn't work out.