You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chamara Gunaratne <ch...@focusinc.com> on 2008/03/05 15:35:18 UTC

short-circuit="true" not working in field validator

Hello,

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. 

 

The app is running in Tomcat 5.5.23. I've tested with both Windows and Linux
and the result is the same. These are the struts libraries that I am using
(placed in the WEB-INF/lib of the context) :

freemarker-2.3.8.jar

ognl-2.6.11.jar

struts2-core-2.0.11.jar

xwork-2.1.0.jar

 

I would greatly appreciate any advice on how to solve this problem J

 

Chamara

 

 

 


RE: short-circuit="true" not working in field validator

Posted by Dave Newton <ne...@yahoo.com>.
--- Chamara Gunaratne <ch...@focusinc.com> wrote:
> Is anybody using the short-circuit attribute in the validations
> successfully? 

Yes.

I'm not in front of my dev machine so I can't do much more at the moment. I
don't recall seeing anything wrong with your configuration.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Chamara Gunaratne <ch...@focusinc.com>.
Is anybody using the short-circuit attribute in the validations
successfully? 

-----Original Message-----
From: Chamara Gunaratne [mailto:chamara.gunaratne@focusinc.com] 
Sent: Wednesday, March 05, 2008 12:56 PM
To: 'Struts Users Mailing List'
Subject: RE: short-circuit="true" not working in field validator

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Wednesday, March 05, 2008 12:38 PM
To: Struts Users Mailing List
Subject: Re: short-circuit="true" not working in field validator

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" <ch...@focusinc.com>
To: "'Struts Users Mailing List'" <us...@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:newton.dave@yahoo.com]
> 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 <ch...@focusinc.com> 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
>
>

Martin:
The first name and last name validation examples that I've given are not
that complex. Yes, they can be combined into one validation rule using the
regex. 

But there are more complex input validations where for the sake of clarity
and ease of debugging, I would like to break up the validation into several
rules. Right now, without the short-circuit working, this causes several
error messages to be displayed for each input field.
Cheers,

Chamara


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Chamara Gunaratne <ch...@focusinc.com>.
-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Wednesday, March 05, 2008 12:38 PM
To: Struts Users Mailing List
Subject: Re: short-circuit="true" not working in field validator

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" <ch...@focusinc.com>
To: "'Struts Users Mailing List'" <us...@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:newton.dave@yahoo.com]
> 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 <ch...@focusinc.com> 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
>
>

Martin:
The first name and last name validation examples that I've given are not
that complex. Yes, they can be combined into one validation rule using the
regex. 

But there are more complex input validations where for the sake of clarity
and ease of debugging, I would like to break up the validation into several
rules. Right now, without the short-circuit working, this causes several
error messages to be displayed for each input field.
Cheers,

Chamara


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: short-circuit="true" not working in field validator

Posted by Dave Newton <ne...@yahoo.com>.
--- Martin Gainty <mg...@hotmail.com> wrote:
> 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?

The regex validator will not signal an error if the value is empty or null. 

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: short-circuit="true" not working in field validator

Posted by Martin Gainty <mg...@hotmail.com>.
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" <ch...@focusinc.com>
To: "'Struts Users Mailing List'" <us...@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:newton.dave@yahoo.com]
> 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 <ch...@focusinc.com> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Chamara Gunaratne <ch...@focusinc.com>.
-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
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 <ch...@focusinc.com> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Chamara Gunaratne <ch...@focusinc.com>.
Dave:
Thank you for your help and advice. That indeed was the problem. I changed
my app to use server side validation and now it is functioning as expected.
Best regards,

Chamara

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Friday, March 07, 2008 6:41 PM
To: Struts Users Mailing List
Subject: RE: short-circuit="true" not working in field validator

--- Chamara Gunaratne <ch...@focusinc.com> wrote:
> <s:form action="ApplicationSubmitAction.do" validate="true">

Ah.

I'm not sure that the short-circuiting behavior works with client-side
validation, although it probably should. I don't see any code in the
generated JavaScript, however, that would enforce short-circuiting behavior.

You may want to file a JIRA regarding this issue (if one hasn't been
already); I think it's reasonable to assume that client-side validation
should also short-circuit if the attribute is set.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


__________ NOD32 2930 (20080307) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Dave Newton <ne...@yahoo.com>.
--- Chamara Gunaratne <ch...@focusinc.com> wrote:
> <s:form action="ApplicationSubmitAction.do" validate="true">

Ah.

I'm not sure that the short-circuiting behavior works with client-side
validation, although it probably should. I don't see any code in the
generated JavaScript, however, that would enforce short-circuiting behavior.

You may want to file a JIRA regarding this issue (if one hasn't been
already); I think it's reasonable to assume that client-side validation
should also short-circuit if the attribute is set.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Chamara Gunaratne <ch...@focusinc.com>.
Dave:
Thank you, here's the files:

ApplicationAction-validation.xml:

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
1.0.2//EN"
       "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">

   <validators>
   
   <field name="user.firstName">
         <field-validator type="requiredstring" 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 or
periods</message>
         </field-validator>
   </field>
  
   <field name="user.lastName">
         <field-validator type="requiredstring" 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 or
periods</message>
         </field-validator>
   </field>
  
</validators>

jsp:

<s:form action="ApplicationSubmitAction.do" validate="true">
 <s:textfield size="30" cssClass="inputtext" label="Email" name="user.email"
maxlength="100" />
 <s:textfield size="30" cssClass="inputtext" label=" First Name"
name="user.firstName" required="true" requiredposition="left" maxlength="50"
/>
 <s:textfield size="30" cssClass="inputtext" label=" Last Name"
name="user.lastName" required="true" requiredposition="left" maxlength="50"
/>
 <s:textfield cssClass="inputtext" label=" Date of Birth (mm/dd/yyyy)"
name="user.dob" required="true" requiredposition="left" maxlength="10" />
 <s:textfield size="30" cssClass="inputtext" label=" Address 1"
name="user.address1" required="true" requiredposition="left" maxlength="100"
/>
 <s:textfield size="30" cssClass="inputtext" label="Address 2"
name="user.address2" maxlength="100" />
 <s:textfield size="30" cssClass="inputtext" label=" City" name="user.city"
required="true" requiredposition="left" maxlength="100" />
 <s:select    cssClass="inputtext" label=" State" name="user.stateId"
list="#application.StatesInApplicationContext" listKey="state_id"
listValue="state" required="true" requiredposition="left" />
 <s:textfield size="05" cssClass="inputtext" label=" ZIP Code"
name="user.zip" required="true" requiredposition="left" maxlength="5" />
				
 <s:submit type="button" cssClass="btn" align="center" label="Submit my
application" value="%{'Submit'}" />
</s:form>

struts.xml action:

<constant name="struts.devMode" value="true" />

<package name="test-default" namespace="/applications"
extends="struts-default">

        <action name="ApplicationSubmitAction.do"
class="test.action.ApplicationAction">
            <result name="success" type="redirect">thanks.html</result>
            <result name="input">/applications/application.jsp</result>
        </action>

</package>


-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Friday, March 07, 2008 6:00 PM
To: Struts Users Mailing List
Subject: RE: short-circuit="true" not working in field validator

Please repost your configs, JSP, and action; I'll look at it again.

Dave

--- Chamara Gunaratne <ch...@focusinc.com> wrote:

> Hmmm, I tried setting the log level to DEBUG and it yielded a mass of
> logging entries, but nothing that was particularly insightful. Grepping on
> short-circuit, validator, etc didn't bring out anything useful.
> 
> Very strange problem, everything else seems to be working fine and I
cannot
> find anywhere I have deviated from the documentation ...
> 
> Chamara
> 
> -----Original Message-----
> From: news [mailto:news@ger.gmane.org] On Behalf Of Laurie Harper
> Sent: Wednesday, March 05, 2008 2:44 PM
> To: user@struts.apache.org
> Subject: Re: short-circuit="true" not working in field validator
> 
> Chamara Gunaratne wrote:
> > 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,
> 
> AFAICT from the Validation documentation, it should be working as you 
> expect. I would suggest turning logging up to DEBUG for Struts and/or 
> XWork (probably XWork?) and see if you get anything that sheds light on 
> what's going wrong.
> 
> L.
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Dave Newton <ne...@yahoo.com>.
Please repost your configs, JSP, and action; I'll look at it again.

Dave

--- Chamara Gunaratne <ch...@focusinc.com> wrote:

> Hmmm, I tried setting the log level to DEBUG and it yielded a mass of
> logging entries, but nothing that was particularly insightful. Grepping on
> short-circuit, validator, etc didn't bring out anything useful.
> 
> Very strange problem, everything else seems to be working fine and I cannot
> find anywhere I have deviated from the documentation ...
> 
> Chamara
> 
> -----Original Message-----
> From: news [mailto:news@ger.gmane.org] On Behalf Of Laurie Harper
> Sent: Wednesday, March 05, 2008 2:44 PM
> To: user@struts.apache.org
> Subject: Re: short-circuit="true" not working in field validator
> 
> Chamara Gunaratne wrote:
> > 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,
> 
> AFAICT from the Validation documentation, it should be working as you 
> expect. I would suggest turning logging up to DEBUG for Struts and/or 
> XWork (probably XWork?) and see if you get anything that sheds light on 
> what's going wrong.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> __________ NOD32 2924 (20080305) Information __________
> 
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Chamara Gunaratne <ch...@focusinc.com>.
Hmmm, I tried setting the log level to DEBUG and it yielded a mass of
logging entries, but nothing that was particularly insightful. Grepping on
short-circuit, validator, etc didn't bring out anything useful.

Very strange problem, everything else seems to be working fine and I cannot
find anywhere I have deviated from the documentation ...

Chamara

-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Laurie Harper
Sent: Wednesday, March 05, 2008 2:44 PM
To: user@struts.apache.org
Subject: Re: short-circuit="true" not working in field validator

Chamara Gunaratne wrote:
> 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,

AFAICT from the Validation documentation, it should be working as you 
expect. I would suggest turning logging up to DEBUG for Struts and/or 
XWork (probably XWork?) and see if you get anything that sheds light on 
what's going wrong.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


__________ NOD32 2924 (20080305) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: short-circuit="true" not working in field validator

Posted by Chamara Gunaratne <ch...@focusinc.com>.
Thank you, I will try that out and see. I guess it is XWork, at least from
what I can figure out from the documentation.

Chamara

-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Laurie Harper
Sent: Wednesday, March 05, 2008 2:44 PM
To: user@struts.apache.org
Subject: Re: short-circuit="true" not working in field validator

Chamara Gunaratne wrote:
> 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,

AFAICT from the Validation documentation, it should be working as you 
expect. I would suggest turning logging up to DEBUG for Struts and/or 
XWork (probably XWork?) and see if you get anything that sheds light on 
what's going wrong.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


__________ NOD32 2924 (20080305) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: short-circuit="true" not working in field validator

Posted by Laurie Harper <la...@holoweb.net>.
Chamara Gunaratne wrote:
> 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,

AFAICT from the Validation documentation, it should be working as you 
expect. I would suggest turning logging up to DEBUG for Struts and/or 
XWork (probably XWork?) and see if you get anything that sheds light on 
what's going wrong.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: short-circuit="true" not working in field validator

Posted by Dave Newton <ne...@yahoo.com>.
--- Chamara Gunaratne <ch...@focusinc.com> 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



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org