gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.52k stars 375 forks source link

Issue with GWT validation process #8380

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 8394

Hi Guys,
I'm trying to implement GWT validator in my project. I made changes referencing GWT
validation sample, but when I'm trying to validate my class "Set<ConstraintViolation<DisplayName>>
violations = validator.validate(sdn);" i'm getting an error "Deferred binding failed
for 'mypackagename._DisplayNameValidator' (did you forget to inherit a required module?)".
Does anybody have an idea what I'm doing wrong?

Thanks,
Andrey.
I added this code to my xml:
<!-- Inherit the validator.                        -->
<inherits name="org.hibernate.validator.HibernateValidator" />

<replace-with
  class="com.bricksimple.thunderdome.client.validation.SampleValidatorFactory">
  <when-type-is class="javax.validation.ValidatorFactory" />
</replace-with> 

this is my constraint:
@NotNull
@ReportAsSingleViolation
@Size(min = 1, message = "{Statement name cannot be Empty}")
//@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {Test_DisplayNameValidator.class})
public @interface Statement_DisplayName
{
  String                          message( )    default "{Statement DisplayName can
not be empty}";
  Class< ? >[ ]                   groups( )     default { };
  Class< ? extends Payload >[ ]   payload( )    default { };
}

this is my "Validator"
public class Test_DisplayNameValidator implements ConstraintValidator<Statement_DisplayName,
DisplayName> {

  public void initialize(Statement_DisplayName constraintAnnotation) {
    // Here I do something that will not compile on GWT
    Method[] methods = constraintAnnotation.getClass().getMethods();
  }

@Override
public boolean isValid(DisplayName value,
        ConstraintValidatorContext context) {
    if (value.getDisplayName().isEmpty() ) {
          return false;
        }
    return true;
}
}

Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):

Workaround if you have one:

Links to relevant GWT Developer Forum posts:

Link to patch posted at http://gwt-review.googlesource.com

Reported by andrey@bricksimple.com on 2013-10-14 13:38:03

dankurka commented 9 years ago
This is the GWT issue tracker, if you are looking for help on how to use GWT use the
user group: https://groups.google.com/forum/#!forum/google-web-toolkit

Reported by dankurka@google.com on 2013-10-16 16:03:55