by what Im seeing from XWork validators the first 'required' validator you declared is unnecessary as the second regex validator will identify that condition http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/va lidator/Validator.html
Anyone? M- ----- Original Message ----- From: "Chamara Gunaratne" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <user@struts.apache.org> Sent: Wednesday, March 05, 2008 11:16 AM Subject: RE: short-circuit="true" not working in field validator > -----Original Message----- > From: Dave Newton [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 05, 2008 10:54 AM > To: Struts Users Mailing List > Subject: Re: short-circuit="true" not working in field validator > > --- Chamara Gunaratne <[EMAIL PROTECTED]> wrote: > > I am using struts2 to validate form input. For some reason I can't figure > > out, the short-circuit="true" attribute is not working. Everything else > > seems to be working fine. The validation rules are embedded in a > > action_class_name-validation.xml file. Here's a sample from the xml file: > > > > <validators> > > <field name="user.firstName"> > > <field-validator type="required" short-circuit="true" > > > <message>Please enter your first name.</message> > > </field-validator> > > > > <field-validator type="regex" short-circuit="true" > > > <param name="expression">^[a-z.\-, A-Z]+$</param> > > <message>First Name may only contain letters, spaces, dashes, > > or > > periods</message> > > </field-validator> > > </field> > > > > <field name="user.lastName"> > > <field-validator type="required" short-circuit="true" > > > <message>Please enter your last name.</message> > > </field-validator> > > <field-validator type="regex" short-circuit="true" > > > <param name="expression">^[a-z.\-, A-Z]+$</param> > > <message>Last Name may only contain letters, spaces, dashes, > or > > periods</message> > > </field-validator> > > </field> > > > > </validators> > > > > If the form is submitted with a blank user.firstName field, I would get > > both > > error messages. From what I understand of how the validations work, only > > the > > first test would fire if short-circuit is enabled. > > I'm surprised the first "required" validator is firing at all; normally > you'd > use "requiredstring" for a text field; a "required" validator will never > (more or less) fire for a text field in an HTML form. > > Is the lastName validation working properly? If so then perhaps you've > spelled the name of your field wrong on the form. > > Dave > > > Dave: > Thank you for your reply. I changed type attribute to "requiredstring". But > it doesn't help with the short-circuit problem. > > Yes, both the first name and last name validators fire successfully and the > regex is correctly evaluated. Just the short-circuit part is not working. > > For example, if I submit a blank first name field, I get both error > messages: "Please enter your first name" and "First Name may only contain > letters, spaces, dashes, or periods". > Cheers, > > Chamara > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]