aspose file tools*
The moose likes Struts and the fly likes Checkbox/Multibox validation in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Checkbox/Multibox validation in Struts" Watch "Checkbox/Multibox validation in Struts" New topic
Author

Checkbox/Multibox validation in Struts

Krid Steel
Greenhorn

Joined: Nov 02, 2005
Posts: 2
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

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Krid Steel
Greenhorn

Joined: Nov 02, 2005
Posts: 2
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checkbox/Multibox validation in Struts