• 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

Validation

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am reading data from database and display it with a checkbox. So number of checkboxes are dynamic, I could have 1 to n check boxes.
I want the user to check all of the boxes before submitting the form.
Question: In validation how to validate that all boxes are checked, since number of boxes are dynamic?

My JSP page

Thank you in advance
Garandi
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i hate to say this up front, but why have checkboxes if they're gonna be checked anyway? can't you display a fake 'checked' images and keep the values in a hidden field?
<p />
in any case, you'll need to do custom validation.
1. pass the number of items into a hidden field (you can use the varStatus attribute of the c:forEach tag to keep a counter, or have it passed to the page in the request, or set it in the action using form.set("hiddenFieldName",checkboxCollectionCount)).

2. add a custom validation method to check the number of checkboxes checked agains the value in the hidden field (see this link - validateTwoFields example for how to set up custom validation - http://struts.apache.org/userGuide/dev_validator.html)
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic