failed to using composition of constraints

39 views
Skip to first unread message

Павел Шацких

unread,
Jul 4, 2012, 6:18:06 AM7/4/12
to gwt-val...@googlegroups.com
Hi!
Currently I'm using gwt-validation 2.1 with GWT 2.4 and Sencha GXT 3. I'm trying to validate simple pojo:
public class SimpleBean {

    @NotEmpty
    private String firstName;
    @Size(min = 3, max = 32)
    private String secondName;
    @Size(min = 3, max = 32)
    private String lastName;
    @Past
    private Date dob;

// getters and setters
}

Fields annotated with @Size and @Past working well, but when gwt-validation try execute validation on firstName (annotated with com.em.validation.client.constraints.NotEmpty) it's fall with
ValidationException("The ConstraintValidator of type " + key.getName() + " was not available as a constraint at code generation time.") in generated file com.em.validation.client.generated.factory.GeneratedConstraintValidatorFactory because there are no com.em.validation.client.validators.NotNullObjectValidator registered in this file. 

Could you please explain what I'm doing wrong?

Thx

chris.r

unread,
Jul 4, 2012, 10:46:00 AM7/4/12
to gwt-val...@googlegroups.com
I don't think you're doing anything wrong.  There was a bug in 2.1 (fixed in r339) that prevented composed constraints from reporting the proper validatedBy class.  There are two fixes for this issue.

The first is to get the trunk and build 2.2-SNAPSHOT for yourself.  I haven't released this yet because, well, I just haven't gotten around to it.  (It just got checked in a few days ago.)

The second is to manually use @NotNull and @Size(min=1) constraints on your firstName field and see if that fixes the issue.  If it does then you can  use that until a suitable 2.2 build is available.

It is also worthwhile to note that using @NotNull anywhere else would also fix this issue.  The defect (https://code.google.com/p/gwt-validation/issues/detail?can=2&q=93&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&id=93) was that composed constraints didn't recursively resolve children (composing) constraints.

So, hopefully you can work around or upgrade to fix your issue.

Good luck!

Павел Шацких

unread,
Jul 4, 2012, 10:57:56 AM7/4/12
to gwt-val...@googlegroups.com
Thank you for your answer Chris! For now I'll try use second variant and later try upgrade to 2.2 version. 

среда, 4 июля 2012 г., 18:46:00 UTC+4 пользователь chris.r написал:
Reply all
Reply to author
Forward
0 new messages