This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Struts and the fly likes Handling Multiple check boxes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Handling Multiple check boxes " Watch "Handling Multiple check boxes " New topic

Handling Multiple check boxes

Sreek Gupta

Joined: Mar 08, 2006
Posts: 24
I have a Collection of value objects(say Employee(Id, name, dateOfBirth,valid etc..). One Action sets the collection in session and forwards to a JSP that displays a list of Employees using <logic:iterate> over this collection.
On each row of Employee information, one checkbox is provided to select whether employee is valid or not. Now if I select multiple checkboxes and submit the form(in JSP), I need the ActionForm to have a Collection that has Employee value objects. For this i declared String[] getters and setters for all the fields. Unfortunately i couldnt get unchecked values in my action form.
How can i get all the entries (whether it is checked or unchecked).
Please help me with code samples if possible.

Alana Sparx
Ranch Hand

Joined: Feb 14, 2006
Posts: 121
I think there is a solution involving the struts multibox control.

Your action form needs to declare 2 arrays - one to hold the entire collection of choices, and one to store the 'checked' choices.

Summat along the lines of

I *think* that's how it's done. I'll leave you to find out about re-setting the array!!

I agree. Here's the link:
subject: Handling Multiple check boxes
It's not a secret anymore!