I have dynamic number of checkboxes in jsp page as given below.
<s:iterator value="details" status="stat">
<s:checkbox name="checkbox" theme="simple" />
<s:hidden name="hidden" value="%{top}" />
</s:iterator>
Let's say 4 checkboxes.
and setter in action class is
public void setCheckbox(boolean s[])
{
System.out.println(s.length);
}
If I don't select any checkbox, s.length
is zero.
If I select 3rd checkbox, s.lenght
is 1 and it is initializing s[0]
with true
.
But problem is here how can I find whether 3rd checkbox is selected or another checkbox is selected.
I thought that setter would initialize s[]={false,false,true,false}
, if I select third checkbox. But it is initializing s[]={true}
.
Corresponding hidden values of those selected boxes are required to perform required action in database. But for that I need to find select checkboxes.
Please suggest me any solution.