You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Balázs Palcsó (JIRA)" <ji...@apache.org> on 2013/12/07 17:17:35 UTC

[jira] [Commented] (TAP5-2254) BeanEditForm autofocus issue with JSR 303 validaiton mixed with tapestry validation

    [ https://issues.apache.org/jira/browse/TAP5-2254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13842255#comment-13842255 ] 

Balázs Palcsó commented on TAP5-2254:
-------------------------------------

5.3.7 might be affected as well. I did not test it.

> BeanEditForm autofocus issue with JSR 303 validaiton mixed with tapestry validation
> -----------------------------------------------------------------------------------
>
>                 Key: TAP5-2254
>                 URL: https://issues.apache.org/jira/browse/TAP5-2254
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Balázs Palcsó
>
> I have the following BeanEditForm:
> {code}
> <t:beaneditform t:id="userRegistrationForm" t:object="user" t:submitLabel="${message:registrationButton-label}"
> include="username,lastName,firstName,email,phone,password,confirmPassword,newsletter">
> </t:beaneditform>
> {code}
> Backed by a User class with these properties:
> {code}
> @NotNull
> @NotBlank
> @Size(min = 3, max = 30)
> private String firstName;
> @NotNull
> @NotBlank
> @Size(min = 3, max = 30)
> private String lastName;
> @NotNull
> @NotBlank
> @Size(min = 3, max = 20)
> @Pattern(regexp = ValidationConstants.USERNAME_REGEXP, message = "{com.ajanlatotkapok.user.User.username-pattern-message}")
> private String username;
> @NotNull
> @NotBlank
> @Email
> private String email;
> @Pattern(regexp = ValidationConstants.PHONE_NUMBER_REGEXP, message = "{phone-regexp-message}")
> @Size(min = 9, max = 20)
> private String phone;
> @Validate("password")
> @Transient
> private String password;
> @Validate("password")
> @Transient
> private String confirmPassword;
> {code}
> The definition of @Validate("password") which makes the password field the first required field in the form (and making it to owner of the focus on the form)
> {code}
> @Contribute(ValidatorMacro.class)
> public static void combinePasswordValidators(final MappedConfiguration<String, String> configuration) {
>     configuration.add("password", "required,minlength=5,maxlength=50,regexp=" + ValidationConstants.PASSWORD_REGEXP);
> }
> {code}
> It seems that only tapestry's @Validate fields are considered when determining which field of the BeanEditForm is the first required field on the form ignoring @NotNull and @NotBlank JSR-303 annotations.
> As a workaround I can annotate all required fields with @Validate("required"), though I would prefer to stick with only JSR-303 where I can.



--
This message was sent by Atlassian JIRA
(v6.1#6144)