You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Aaron Freeman (JIRA)" <ji...@apache.org> on 2007/10/23 07:32:39 UTC

[jira] Updated: (WW-2270) Generated JavaScript for validators does not honor the short-circuit attribute

     [ https://issues.apache.org/struts/browse/WW-2270?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aaron Freeman updated WW-2270:
------------------------------

    Attachment: form-close-validate.ftl

This is the ftl wih my modifications

> Generated JavaScript for validators does not honor the short-circuit attribute
> ------------------------------------------------------------------------------
>
>                 Key: WW-2270
>                 URL: https://issues.apache.org/struts/browse/WW-2270
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Validation
>    Affects Versions: 2.0.10
>            Reporter: Aaron Freeman
>         Attachments: form-close-validate.ftl
>
>
> When you put several validators on a field, like a required and a regex validator, you can specify that the second validator should not be run if the first one fails by setting the short-circuit attribute. However, when you set validate='true' on a form, the JavaScript that is generated does not honor the short-circuit attribute. It will always run both validations.
> The JavaScript is generated by the Freemarker code in form-close-validate.ftl
> I fixed this for my app by adding "var continueValidation = true;" outside the loop, then adding "<#if validator.shortCircuit>continueValidation = false;</#if>" on the line after "errors = true;" in each 'if' block. Then added 'continueValidation && ' to the front of each if.
> This seemed to work just fine.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.