• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling Multiple check boxes

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic