• 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

Checkbox/Multibox validation in Struts

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm trying to validate a form, which has some multiboxes in it. the user has to choose at least one or more checkboxes checked. How can this be achieved using the struts validator framework? The corresponding form field is an array of string (String[]). Does anybody have an idea? I do not want to code the validate method because of the potentially changing requirements.

I've set the element to required (<field property="l" depends="required"> , but the applications fails with an StackOverflowError.


It looks to me like the application is looping somehow...

any help appreciated...
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might try overriding the reset method on your form bean and having it initialize the String array to an empty array (i = new String[0]). Otherwise, this value could be null, which might cause the error.
 
Krid Steel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

thanks for the answer, i could get it working for the validation using the validate method inside the form bean (the stackoverflow was caused by a misconfiguration in struts-config.xml).

but the initialisation using the new String[0] in the forms reset method does not report an error with the "required" flag for the checkbox in validation.xml. the open issue is still how to validate using the validate.xml if at least one checkbox has been selected.

any ideas? thanks in advance...
 
Evacuate the building! Here, take this tiny ad with you:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic