This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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...
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). Otherwise, this value could be null, which might cause the error.
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 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.