struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerome Chin (JIRA)" <>
Subject [jira] [Created] (WW-3827) Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.
Date Mon, 28 May 2012 17:27:23 GMT
Jerome Chin created WW-3827:

             Summary: Generated Javascript validation short-circuit one field, will short-circuit
all the remaining fields.
                 Key: WW-3827
             Project: Struts 2
          Issue Type: Bug
          Components: XML Validators
    Affects Versions: 2.3.3, 2.2.1
            Reporter: Jerome Chin
         Attachments: form-close-validate.ftl

When you set up your validation.xml with short-circuit and use client-side validation by setting
validate="true" in the s:form tag.

if one of the field has a short-circuited field-validator, the remaining generated javascript
validations will be short-circuited as well.

For example, the following validation xml, if password has error, phone number will not be
validate at all in the client-side.
<field name="password">
    <field-validator type="requiredstring" short-circuit="true">
      <param name="trim">true</param>
      <message key="ERROR.REQUIRED_LOGIN_PASSWORD"/>
    <field-validator type="fieldexpression" short-circuit="true">
        <param name="expression">password==confirmPassword</param>
        <message key="ERROR.CONFIRM_PASSWORD"/>
    <field-validator type="stringlength">
      <param name="trim">true</param>
      <param name="minLength">6</param>
      <message key="ERROR.PASSWORD_TOO_SHORT"/>
  <field name="phoneNumber">
    <field-validator type="requiredstring" short-circuit="true">
      <param name="trim">true</param>
      <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
    <field-validator type="regex">
      <param name="trim">true</param>      
      <param name="expression"><![CDATA[^(\(?\d\d\d\)?)?( |-|\.)?\d\d\d( |-|\.)?\d{4,4}((
|-|\.)?[ext\.]+ ?\d+)?$]]></param>
      <message key="ERROR.INVALID_PHONE_NUMBER"/>

This seems to be caused but the continueValidation flag in the form-close-validate.ftl freemarker

I've added a line in the template to reset the continueValidation flag at the start of each
... snip ...
<#list parameters.tagNames as tagName>
    	<#-- Fix issue with short-circuit one field-validator will short-circuit field-validators
of other field name as well -->
    	// field validators for tag, ${tagName}
    	continueValidation = true;  // reset flag, as we are starting a new field name.
        <#list tag.getValidators("${tagName}") as validator>
... snip ...

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message