• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checkbox/Multibox validation in Struts

 
Krid Steel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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...
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic