Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling Multiple check boxes

 
Sreek Gupta
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.

Regds,
Sreek
 
Alana Sparx
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!

As!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic