You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Musachy Barroso (JIRA)" <ji...@apache.org> on 2008/05/23 02:58:05 UTC
[jira] Commented: (WW-2306) @StringLengthFieldValidator annotation
fires a different times according to placement
[ https://issues.apache.org/struts/browse/WW-2306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43932#action_43932 ]
Musachy Barroso commented on WW-2306:
-------------------------------------
Ted, I am not able to reproduce this, I modified org.apache.struts2.showcase.validation.FieldValidatorsExampleAction (first I removed xml validation), and added this to the class:
@Validation
@Validations(
requiredStrings = {@RequiredStringValidator(fieldName = "requiredValidatorField", message = "missing field")},
stringLengthFields = { @StringLengthFieldValidator(fieldName = "requiredValidatorField", message = "invalid size", trim = true, minLength = "4", maxLength = "12") })
I got the "missing field" error when I submitted the for with the field empty, and "invalid size" when the size was wrong. I tried moving the annotations to the method:
@RequiredStringValidator(message = "missing field")
@StringLengthFieldValidator(fieldName = "requiredValidatorField", message = "invalid size", trim = true, minLength = "4", maxLength = "12")
with the same results. Can you still reproduce this?
> @StringLengthFieldValidator annotation fires a different times according to placement
> -------------------------------------------------------------------------------------
>
> Key: WW-2306
> URL: https://issues.apache.org/struts/browse/WW-2306
> Project: Struts 2
> Issue Type: Bug
> Reporter: Ted Husted
> Fix For: 2.1.4
>
>
> Express a @StringLengthFieldValidator using the idiom
> @Validations (
> stringLengthFields = {
> @StringLengthFieldValidator(fieldName="password1", key="error.password.length", message="", trim = true, minLength = "4", maxLength = "12")
> })
> on an alias method, and it fires before any validations (such as @RequiredString), short -circuiting them, even when short-circuit is not set. It also fires when input is empty (rather than at >0).
> The same thing happens when the annotation is applied to the get method.
> @StringLengthFieldValidator(fieldName="password1", key="error.password.length", message="", trim = true, minLength = "4", maxLength = "12")
> @ExpressionValidator(key="error.password.match", message="", expression="password1 eq password2" )
> public String execute() throws Exception {
> Ideally, @StringLengthFieldValidator should fire at the same time @EmailValidator and the like fire.
> -Ted.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.