YES YOU R RIGHT. WHEN THE CHECK BOX IS NOT CHECKED, THE FORM WILL NOT EVEN HAVE THAT ELEMENT PRESENT. THIS IS AN ERROR IN STRUTS.
Did you file a Bugzilla bug report ? If not could you file a Bugilla report, attaching a detailed description and/or
test case is the best way to get this fixed.
Thanks
IN OUR APPLICATION WE WROTE A CODE WHICH CHECK FOR THIS ELEMENT AN IT IS IS NOT THERE THEN MADE IT "FALSE"
ALSO MAKE SURE YOU HAVE isCheckbox():return boolean instead if getCheckbox():return String in your action form.
-----Original Message----- From: Greg Amaroso [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2003 7:48 AM To: Struts Users Mailing List Subject: Re: Struts form validation of radio buttons and checkboxes
Thanks for the response, but I don't think the problem lies with the actual validation that's happening. I suspect that when a user submits the form page without a checkbox/radio button checked, a blank variable is never sent to the form bean (i.e http://www.url.com/servlet.do?checkboxvar=), it just doesn't send anything. The form bean then sees it as as a nonexistent variable and returns a trace stack error. Any other ideas? I will however update my struts package.
From: Robert Leland <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Date: Wed, 03 Sep 2003 22:09:14 -0400 To: Struts Users Mailing List <[EMAIL PROTECTED]> Subject: Re: Struts form validation of radio buttons and checkboxes
Greg Amaroso wrote:
I'm having trouble with the struts form validation framework when it comes
to radio buttons and checkboxes. For some reason, I can validate any other
type of field, but not radios/checkboxes. Here's where I seem to be having
trouble:
Try a --nightly-- build of struts. I believe it has enhancements in commons-validator to validate radio controls. you can tell for sure by looking at the validator-rules.xml.
In there you'll see itels like :
function validateRequired(form) {
//Stuff deleted.....
if (field.type == 'text' ||
//stuff deleted
field.type == 'radio' ||
field.type == 'password') {
So this says that for the 'required' rule radio is supported.
Do the same for integer, byte, etc to see if 'radio' is supported.
In the struts-config.xml file, should the form-property type be set to java.lang.String or java.lang.Boolean?
In the page with the form, does it look right to create the radio buttons like this: <html:form ......> <html:radio property="activity" value="a" /> <html:radio property="activity" value="b" /> <html:radio property="activity" value="c" /> </html:form>
Are there any other tricks to doing this that differs from validating standard text boxes, textareas, etc.?
Thank in advance.
Greg Amaroso
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]