You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Adam Crume (JIRA)" <ji...@apache.org> on 2007/10/16 22:08:38 UTC

[jira] Created: (WW-2255) Field validators should be skipped if there is a conversion error

Field validators should be skipped if there is a conversion error
-----------------------------------------------------------------

                 Key: WW-2255
                 URL: https://issues.apache.org/struts/browse/WW-2255
             Project: Struts 2
          Issue Type: Improvement
          Components: Validation
            Reporter: Adam Crume


If there is an error converting a field, the validators for that field should be skipped.  For example, let's say I have an action with an "age" field declared as an Integer, and the field is required.  If the user enters "one", the user will see two errors: one from the conversion process, and one from the required validator (since the field was never assigned).

In general, a conversion error should short-circuit all validators for that field, since validators depend on the field being set, which never happens if there was a conversion error.


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


[jira] Updated: (WW-2255) Field validators should be skipped if there is a conversion error

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

Don Brown updated WW-2255:
--------------------------

    Fix Version/s:     (was: 2.1.1)
                   2.1.x

This patch needs a bit more work before it is ready to be applied.  Could you please provide a diff and ideally a few unit tests to show how this fix addresses the issue.  Thanks.

> Field validators should be skipped if there is a conversion error
> -----------------------------------------------------------------
>
>                 Key: WW-2255
>                 URL: https://issues.apache.org/struts/browse/WW-2255
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: XML Validators
>            Reporter: Adam Crume
>             Fix For: 2.1.x
>
>         Attachments: ConversionErrorInterceptor2.java
>
>
> If there is an error converting a field, the validators for that field should be skipped.  For example, let's say I have an action with an "age" field declared as an Integer, and the field is required.  If the user enters "one", the user will see two errors: one from the conversion process, and one from the required validator (since the field was never assigned).
> In general, a conversion error should short-circuit all validators for that field, since validators depend on the field being set, which never happens if there was a conversion error.

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


[jira] Updated: (WW-2255) Field validators should be skipped if there is a conversion error

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

Don Brown updated WW-2255:
--------------------------

    Fix Version/s:     (was: 2.1.x)
                   2.2.x

> Field validators should be skipped if there is a conversion error
> -----------------------------------------------------------------
>
>                 Key: WW-2255
>                 URL: https://issues.apache.org/struts/browse/WW-2255
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: XML Validators
>            Reporter: Adam Crume
>             Fix For: 2.2.x
>
>         Attachments: ConversionErrorInterceptor2.java
>
>
> If there is an error converting a field, the validators for that field should be skipped.  For example, let's say I have an action with an "age" field declared as an Integer, and the field is required.  If the user enters "one", the user will see two errors: one from the conversion process, and one from the required validator (since the field was never assigned).
> In general, a conversion error should short-circuit all validators for that field, since validators depend on the field being set, which never happens if there was a conversion error.

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


[jira] Commented: (WW-2255) Field validators should be skipped if there is a conversion error

Posted by "Tom Schneider (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42714 ] 

Tom Schneider commented on WW-2255:
-----------------------------------

Another way to handle this is to completely remove the conversions error interceptor and use the ConversionValidator in the validaiton xml:
  <field name="groupProfileData.phoneNumber2">

    <field-validator type="conversion" short-circuit="true">

      <message key="4.invalid.number.error">Missing default error message</message>

    </field-validator>

    <field-validator type="phoneNumber" short-circuit="true">

      <message key="18.invalid.phoneNumer.error">Missing default error message</message>

    </field-validator>

  </field>

The short-circuit attribute will ensure that only 1 error message is added.  You run into the same issue if you have more than 1 validator defined per field in the validation xml.

> Field validators should be skipped if there is a conversion error
> -----------------------------------------------------------------
>
>                 Key: WW-2255
>                 URL: https://issues.apache.org/struts/browse/WW-2255
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: XML Validators
>            Reporter: Adam Crume
>             Fix For: 2.1.1
>
>         Attachments: ConversionErrorInterceptor2.java
>
>
> If there is an error converting a field, the validators for that field should be skipped.  For example, let's say I have an action with an "age" field declared as an Integer, and the field is required.  If the user enters "one", the user will see two errors: one from the conversion process, and one from the required validator (since the field was never assigned).
> In general, a conversion error should short-circuit all validators for that field, since validators depend on the field being set, which never happens if there was a conversion error.

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


[jira] Updated: (WW-2255) Field validators should be skipped if there is a conversion error

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

Ted Husted updated WW-2255:
---------------------------

            Flags: [Patch]
    Fix Version/s:     (was: 2.1.3)
                   2.1.1

> Field validators should be skipped if there is a conversion error
> -----------------------------------------------------------------
>
>                 Key: WW-2255
>                 URL: https://issues.apache.org/struts/browse/WW-2255
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Validation
>            Reporter: Adam Crume
>             Fix For: 2.1.1
>
>         Attachments: ConversionErrorInterceptor2.java
>
>
> If there is an error converting a field, the validators for that field should be skipped.  For example, let's say I have an action with an "age" field declared as an Integer, and the field is required.  If the user enters "one", the user will see two errors: one from the conversion process, and one from the required validator (since the field was never assigned).
> In general, a conversion error should short-circuit all validators for that field, since validators depend on the field being set, which never happens if there was a conversion error.

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


[jira] Commented: (WW-2255) Field validators should be skipped if there is a conversion error

Posted by "Crume, Adam (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45381#action_45381 ] 

Crume, Adam commented on WW-2255:
---------------------------------

I will be out of the office until Friday, January 2. Please contact David Carter if you need immediate assistance.

**************************************************************************************************
Note: 
The information contained in this message may be privileged and confidential and 
protected from disclosure.  If the reader of this message is not the intended  
recipient, or an employee or agent responsible for delivering this message to  
the intended recipient, you are hereby notified that any dissemination,   
distribution or copying of this communication is strictly prohibited. If you  
have received this communication in error, please notify us immediately by  
replying to the message and deleting it from your computer. 
**************************************************************************************************


> Field validators should be skipped if there is a conversion error
> -----------------------------------------------------------------
>
>                 Key: WW-2255
>                 URL: https://issues.apache.org/struts/browse/WW-2255
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: XML Validators
>            Reporter: Adam Crume
>             Fix For: 2.2.x
>
>         Attachments: ConversionErrorInterceptor2.java
>
>
> If there is an error converting a field, the validators for that field should be skipped.  For example, let's say I have an action with an "age" field declared as an Integer, and the field is required.  If the user enters "one", the user will see two errors: one from the conversion process, and one from the required validator (since the field was never assigned).
> In general, a conversion error should short-circuit all validators for that field, since validators depend on the field being set, which never happens if there was a conversion error.

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


[jira] Commented: (WW-2255) Field validators should be skipped if there is a conversion error

Posted by "Noel Hernández (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45380#action_45380 ] 

Noel Hernández commented on WW-2255:
------------------------------------

I think that you can't use struts in a real world project without resolve this issue. 
I'm wondering if it works the same in XWork.
I'm using the workaround of Tom Scheneider, thanks Tom, but right now my team mates has loose the confidence in the struts2 project looking at new releases without this issue being solved.

> Field validators should be skipped if there is a conversion error
> -----------------------------------------------------------------
>
>                 Key: WW-2255
>                 URL: https://issues.apache.org/struts/browse/WW-2255
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: XML Validators
>            Reporter: Adam Crume
>             Fix For: 2.2.x
>
>         Attachments: ConversionErrorInterceptor2.java
>
>
> If there is an error converting a field, the validators for that field should be skipped.  For example, let's say I have an action with an "age" field declared as an Integer, and the field is required.  If the user enters "one", the user will see two errors: one from the conversion process, and one from the required validator (since the field was never assigned).
> In general, a conversion error should short-circuit all validators for that field, since validators depend on the field being set, which never happens if there was a conversion error.

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


[jira] Updated: (WW-2255) Field validators should be skipped if there is a conversion error

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

Adam Crume updated WW-2255:
---------------------------

    Attachment: ConversionErrorInterceptor2.java

It's not elegant, but this can be achieved by removing the old conversionError interceptor and adding this modified one *after* the validation interceptor.  It works by overwriting any validation error messages a field has if it has a conversion error.

I had to copy and modify the code in org.apache.struts2.interceptor.StrutsConversionErrorInterceptor and com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor because the logic couldn't be changed easily by subclassing.

> Field validators should be skipped if there is a conversion error
> -----------------------------------------------------------------
>
>                 Key: WW-2255
>                 URL: https://issues.apache.org/struts/browse/WW-2255
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Validation
>            Reporter: Adam Crume
>         Attachments: ConversionErrorInterceptor2.java
>
>
> If there is an error converting a field, the validators for that field should be skipped.  For example, let's say I have an action with an "age" field declared as an Integer, and the field is required.  If the user enters "one", the user will see two errors: one from the conversion process, and one from the required validator (since the field was never assigned).
> In general, a conversion error should short-circuit all validators for that field, since validators depend on the field being set, which never happens if there was a conversion error.

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