You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Jerome Chin (JIRA)" <ji...@apache.org> on 2012/05/28 19:27:23 UTC

[jira] [Created] (WW-3827) Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.

Jerome Chin created WW-3827:
-------------------------------

             Summary: Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.
                 Key: WW-3827
                 URL: https://issues.apache.org/jira/browse/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>
    <field-validator type="fieldexpression" short-circuit="true">
        <param name="expression">password==confirmPassword</param>
        <message key="ERROR.CONFIRM_PASSWORD"/>
    </field-validator>
    <field-validator type="stringlength">
      <param name="trim">true</param>
      <param name="minLength">6</param>
      <message key="ERROR.PASSWORD_TOO_SHORT"/>
    </field-validator>
  </field>
    
  <field name="phoneNumber">
    <field-validator type="requiredstring" short-circuit="true">
      <param name="trim">true</param>
      <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
    </field-validator>
    <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"/>
    </field-validator>
  </field>

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

I've added a line in the template to reset the continueValidation flag at the start of each field:
... 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (WW-3827) Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.

Posted by "Jerome Chin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jerome Chin updated WW-3827:
----------------------------

    Attachment: form-close-validate.ftl
    
> Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.
> -----------------------------------------------------------------------------------------------------
>
>                 Key: WW-3827
>                 URL: https://issues.apache.org/jira/browse/WW-3827
>             Project: Struts 2
>          Issue Type: Bug
>          Components: XML Validators
>    Affects Versions: 2.2.1, 2.3.3
>            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>
>     <field-validator type="fieldexpression" short-circuit="true">
>         <param name="expression">password==confirmPassword</param>
>         <message key="ERROR.CONFIRM_PASSWORD"/>
>     </field-validator>
>     <field-validator type="stringlength">
>       <param name="trim">true</param>
>       <param name="minLength">6</param>
>       <message key="ERROR.PASSWORD_TOO_SHORT"/>
>     </field-validator>
>   </field>
>     
>   <field name="phoneNumber">
>     <field-validator type="requiredstring" short-circuit="true">
>       <param name="trim">true</param>
>       <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
>     </field-validator>
>     <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"/>
>     </field-validator>
>   </field>
> This seems to be caused but the continueValidation flag in the form-close-validate.ftl freemarker template.
> I've added a line in the template to reset the continueValidation flag at the start of each field:
> ... 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (WW-3827) Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-3827:
------------------------------

    Fix Version/s: 2.3.5
    
> Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.
> -----------------------------------------------------------------------------------------------------
>
>                 Key: WW-3827
>                 URL: https://issues.apache.org/jira/browse/WW-3827
>             Project: Struts 2
>          Issue Type: Bug
>          Components: XML Validators
>    Affects Versions: 2.2.1, 2.3.3
>            Reporter: Jerome Chin
>             Fix For: 2.3.5
>
>         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>
>     <field-validator type="fieldexpression" short-circuit="true">
>         <param name="expression">password==confirmPassword</param>
>         <message key="ERROR.CONFIRM_PASSWORD"/>
>     </field-validator>
>     <field-validator type="stringlength">
>       <param name="trim">true</param>
>       <param name="minLength">6</param>
>       <message key="ERROR.PASSWORD_TOO_SHORT"/>
>     </field-validator>
>   </field>
>     
>   <field name="phoneNumber">
>     <field-validator type="requiredstring" short-circuit="true">
>       <param name="trim">true</param>
>       <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
>     </field-validator>
>     <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"/>
>     </field-validator>
>   </field>
> This seems to be caused but the continueValidation flag in the form-close-validate.ftl freemarker template.
> I've added a line in the template to reset the continueValidation flag at the start of each field:
> ... 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3827) Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464067#comment-13464067 ] 

Lukasz Lenart commented on WW-3827:
-----------------------------------

As I understand that's how it should work. Short-circuit should stop any other validations for all remaining fields

http://struts.apache.org/2.x/docs/validation.html#Validation-ShortCircuitingValidator 
                
> Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.
> -----------------------------------------------------------------------------------------------------
>
>                 Key: WW-3827
>                 URL: https://issues.apache.org/jira/browse/WW-3827
>             Project: Struts 2
>          Issue Type: Bug
>          Components: XML Validators
>    Affects Versions: 2.2.1, 2.3.3
>            Reporter: Jerome Chin
>             Fix For: 2.3.5
>
>         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.
> {code:xml}
> <field name="password">
>     <field-validator type="requiredstring" short-circuit="true">
>       <param name="trim">true</param>
>       <message key="ERROR.REQUIRED_LOGIN_PASSWORD"/>
>     </field-validator>
>     <field-validator type="fieldexpression" short-circuit="true">
>         <param name="expression">password==confirmPassword</param>
>         <message key="ERROR.CONFIRM_PASSWORD"/>
>     </field-validator>
>     <field-validator type="stringlength">
>       <param name="trim">true</param>
>       <param name="minLength">6</param>
>       <message key="ERROR.PASSWORD_TOO_SHORT"/>
>     </field-validator>
>   </field>
>     
>   <field name="phoneNumber">
>     <field-validator type="requiredstring" short-circuit="true">
>       <param name="trim">true</param>
>       <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
>     </field-validator>
>     <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"/>
>     </field-validator>
>   </field>
> {code}
> This seems to be caused but the continueValidation flag in the form-close-validate.ftl freemarker template.
> I've added a line in the template to reset the continueValidation flag at the start of each field:
> ... snip ...
> {code:xml}
> <#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>
> {code}
> ... snip ...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (WW-3827) Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-3827:
------------------------------

    Fix Version/s:     (was: 2.3.5)
                   2.3.6
    
> Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.
> -----------------------------------------------------------------------------------------------------
>
>                 Key: WW-3827
>                 URL: https://issues.apache.org/jira/browse/WW-3827
>             Project: Struts 2
>          Issue Type: Bug
>          Components: XML Validators
>    Affects Versions: 2.2.1, 2.3.3
>            Reporter: Jerome Chin
>             Fix For: 2.3.6
>
>         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.
> {code:xml}
> <field name="password">
>     <field-validator type="requiredstring" short-circuit="true">
>       <param name="trim">true</param>
>       <message key="ERROR.REQUIRED_LOGIN_PASSWORD"/>
>     </field-validator>
>     <field-validator type="fieldexpression" short-circuit="true">
>         <param name="expression">password==confirmPassword</param>
>         <message key="ERROR.CONFIRM_PASSWORD"/>
>     </field-validator>
>     <field-validator type="stringlength">
>       <param name="trim">true</param>
>       <param name="minLength">6</param>
>       <message key="ERROR.PASSWORD_TOO_SHORT"/>
>     </field-validator>
>   </field>
>     
>   <field name="phoneNumber">
>     <field-validator type="requiredstring" short-circuit="true">
>       <param name="trim">true</param>
>       <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
>     </field-validator>
>     <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"/>
>     </field-validator>
>   </field>
> {code}
> This seems to be caused but the continueValidation flag in the form-close-validate.ftl freemarker template.
> I've added a line in the template to reset the continueValidation flag at the start of each field:
> ... snip ...
> {code:xml}
> <#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>
> {code}
> ... snip ...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (WW-3827) Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-3827:
------------------------------

    Description: 
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.
{code:xml}
<field name="password">
    <field-validator type="requiredstring" short-circuit="true">
      <param name="trim">true</param>
      <message key="ERROR.REQUIRED_LOGIN_PASSWORD"/>
    </field-validator>
    <field-validator type="fieldexpression" short-circuit="true">
        <param name="expression">password==confirmPassword</param>
        <message key="ERROR.CONFIRM_PASSWORD"/>
    </field-validator>
    <field-validator type="stringlength">
      <param name="trim">true</param>
      <param name="minLength">6</param>
      <message key="ERROR.PASSWORD_TOO_SHORT"/>
    </field-validator>
  </field>
    
  <field name="phoneNumber">
    <field-validator type="requiredstring" short-circuit="true">
      <param name="trim">true</param>
      <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
    </field-validator>
    <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"/>
    </field-validator>
  </field>
{code}

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

I've added a line in the template to reset the continueValidation flag at the start of each field:
... snip ...
{code:xml}
<#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>
{code}
... snip ...



  was:
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>
    <field-validator type="fieldexpression" short-circuit="true">
        <param name="expression">password==confirmPassword</param>
        <message key="ERROR.CONFIRM_PASSWORD"/>
    </field-validator>
    <field-validator type="stringlength">
      <param name="trim">true</param>
      <param name="minLength">6</param>
      <message key="ERROR.PASSWORD_TOO_SHORT"/>
    </field-validator>
  </field>
    
  <field name="phoneNumber">
    <field-validator type="requiredstring" short-circuit="true">
      <param name="trim">true</param>
      <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
    </field-validator>
    <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"/>
    </field-validator>
  </field>

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

I've added a line in the template to reset the continueValidation flag at the start of each field:
... 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 ...



    
> Generated Javascript validation short-circuit one field, will short-circuit all the remaining fields.
> -----------------------------------------------------------------------------------------------------
>
>                 Key: WW-3827
>                 URL: https://issues.apache.org/jira/browse/WW-3827
>             Project: Struts 2
>          Issue Type: Bug
>          Components: XML Validators
>    Affects Versions: 2.2.1, 2.3.3
>            Reporter: Jerome Chin
>             Fix For: 2.3.5
>
>         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.
> {code:xml}
> <field name="password">
>     <field-validator type="requiredstring" short-circuit="true">
>       <param name="trim">true</param>
>       <message key="ERROR.REQUIRED_LOGIN_PASSWORD"/>
>     </field-validator>
>     <field-validator type="fieldexpression" short-circuit="true">
>         <param name="expression">password==confirmPassword</param>
>         <message key="ERROR.CONFIRM_PASSWORD"/>
>     </field-validator>
>     <field-validator type="stringlength">
>       <param name="trim">true</param>
>       <param name="minLength">6</param>
>       <message key="ERROR.PASSWORD_TOO_SHORT"/>
>     </field-validator>
>   </field>
>     
>   <field name="phoneNumber">
>     <field-validator type="requiredstring" short-circuit="true">
>       <param name="trim">true</param>
>       <message key="ERROR.REQUIRED_PHONE_NUMBER"/>
>     </field-validator>
>     <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"/>
>     </field-validator>
>   </field>
> {code}
> This seems to be caused but the continueValidation flag in the form-close-validate.ftl freemarker template.
> I've added a line in the template to reset the continueValidation flag at the start of each field:
> ... snip ...
> {code:xml}
> <#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>
> {code}
> ... snip ...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira