• 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

to validate multibox in a jsp with struts

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using multibox in a jsp page. I have to validate such a way that if any user does not click any box, it should display an error message saying that atleast one checkbox have to be selected.I am working on struts, so i would like to know if there are any autovalidation or in any other way....
Thanks in advance
pav
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're defining this property in a DynaActionForm, specify initial="{}" when you define it in the struts-config.xml file. If you're writing your own ActionForm, overrride the reset(...) method and specify somewhere in that method. Once you've done this, you can simply use the standard "required" validation for this property.

The reason you need to initialize it as an empty String array is that if no checkbox is checked, nothing will get set to the server, and the validation framework doesn't recognize it.
[ November 25, 2007: Message edited by: Merrill Higginson ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic