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