Hi, here is working solution:
Validator validator =
Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<*MODEL*>> violations =
validator.validate(editor.flush());
@SuppressWarnings({ "rawtypes", "unchecked" })
Iterable<ConstraintViolation<?>> violations2 =
(Iterable<ConstraintViolation<?>>) (Set) violations;
if (!violations.isEmpty()) {
editor.setConstraintViolations(violations2);
return;
}
where MODEL is class that you used when declaring interface for editor. IE:
interface MyEditorDriver extends SimpleBeanEditorDriver<MODEL,
SOME_EDITOR> {
}
MyEditorDriver editor;
Cheers,
Milan
On Thursday, February 14, 2013 4:43:48 PM UTC+1, Alexandre Senecal wrote:
>
> Using GWT 2.5.0, I would like to use Client side validation and Editors. I
> encounter the following error when trying to pass the ConstraintViolation
> Set to the EditorDriver as follows.
>
> Validator a = Validation.buildDefaultValidatorFactory().getValidator();
>
> Set<ConstraintViolation<Person>> b = a.validate(person);
>
> editorDriver.setConstraintViolations(b);
>
> The method setConstraintViolations(Iterable<ConstraintViolation<?>>) in
> the type EditorDriver<Person> is not applicable for the arguments
> (Set<ConstraintViolation<Person>>)
>
> The only somewhat relevant post I could find was Issue
> 6270<http://code.google.com/p/google-web-toolkit/issues/detail?id=6270>
>
> I've posted this question on stackoverflow as well, with example code
> (Classes, UiBinder, GWT Module and dependencies).
>
> How to setConstraintViolations on EditorDriver using return value of
> client side Validator Validate method
> call<http://stackoverflow.com/questions/14878501/how-to-setconstraintviolations-on-editordriver-using-return-value-of-client-side>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.