Fwd: BeanEditForm autofocus issue with JSR 303 validaiton mixed with tapestry validation (Tapestry 5.4-alpha-29)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: BeanEditForm autofocus issue with JSR 303 validaiton mixed with tapestry validation (Tapestry 5.4-alpha-29)

balapal
Hi All,

I have the following BeanEditForm:

<t:beaneditform t:id=*"userRegistrationForm"* t:object=*"user"*
t:submitLabel="${message:registrationButton-label}"

include=
*"username,lastName,firstName,email,phone,password,confirmPassword,newsletter"*
>

</t:beaneditform>

Backed by a User class with these properties:

@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;

By default the autofocus is enabled for the BeanEditForm and it seems that
only tapestry's @Validate fields are considered when determining which
field 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.

Shall I raise a bug in JIRA?

Thanks and regards,
Balazs Palcso
Reply | Threaded
Open this post in threaded view
|

Re: BeanEditForm autofocus issue with JSR 303 validaiton mixed with tapestry validation (Tapestry 5.4-alpha-29)

balapal
I forgot to post 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)

@Contribute(ValidatorMacro.*class*)

*public* *static* *void*
combinePasswordValidators(*final*MappedConfiguration<String, String>
configuration) {

configuration.add("password", "required,minlength=5,maxlength=50,regexp=" +
ValidationConstants.*PASSWORD_REGEXP*);

}




On 5 December 2013 21:43, Balázs Palcsó <[hidden email]> wrote:

> Hi All,
>
> I have the following BeanEditForm:
>
> <t:beaneditform t:id=*"userRegistrationForm"* t:object=*"user"*
> t:submitLabel="${message:registrationButton-label}"
>
> include=
> *"username,lastName,firstName,email,phone,password,confirmPassword,newsletter"*
> >
>
> </t:beaneditform>
>
> Backed by a User class with these properties:
>
> @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;
>
> By default the autofocus is enabled for the BeanEditForm and it seems that
> only tapestry's @Validate fields are considered when determining which
> field 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.
>
> Shall I raise a bug in JIRA?
>
> Thanks and regards,
> Balazs Palcso
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: BeanEditForm autofocus issue with JSR 303 validaiton mixed with tapestry validation (Tapestry 5.4-alpha-29)

balapal
I have raised a bug in JIRA for this:
https://issues.apache.org/jira/browse/TAP5-2254


On 5 December 2013 22:22, Balázs Palcsó <[hidden email]> wrote:

> I forgot to post 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)
>
> @Contribute(ValidatorMacro.*class*)
>
> *public* *static* *void* combinePasswordValidators(*final*MappedConfiguration<String, String> configuration) {
>
> configuration.add("password", "required,minlength=5,maxlength=50,regexp="+ ValidationConstants.
> *PASSWORD_REGEXP*);
>
> }
>
>
>
>
> On 5 December 2013 21:43, Balázs Palcsó <[hidden email]> wrote:
>
>> Hi All,
>>
>> I have the following BeanEditForm:
>>
>> <t:beaneditform t:id=*"userRegistrationForm"* t:object=*"user"*
>> t:submitLabel="${message:registrationButton-label}"
>>
>> include=
>> *"username,lastName,firstName,email,phone,password,confirmPassword,newsletter"*
>> >
>>
>> </t:beaneditform>
>>
>> Backed by a User class with these properties:
>>
>> @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;
>>
>> By default the autofocus is enabled for the BeanEditForm and it seems
>> that only tapestry's @Validate fields are considered when determining which
>> field 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.
>>
>> Shall I raise a bug in JIRA?
>>
>> Thanks and regards,
>> Balazs Palcso
>>
>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: BeanEditForm autofocus issue with JSR 303 validaiton mixed with tapestry validation (Tapestry 5.4-alpha-29)

Thiago H de Paula Figueiredo
On Sat, 07 Dec 2013 14:13:10 -0200, Balázs Palcsó  
<[hidden email]> wrote:

> I have raised a bug in JIRA for this:
> https://issues.apache.org/jira/browse/TAP5-2254

Thanks!

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
Help me spend a whole month working on Tapestry bug fixes and  
improvements: http://igg.me/at/t5month

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]