Editor Framework and BeanValidation (setConstraintViolations problem).

279 views
Skip to first unread message

Ümit Seren

unread,
Aug 28, 2012, 11:11:20 AM8/28/12
to google-we...@googlegroups.com

I am trying to get the Editor Framework to work with BeanValidation (JSR303) (GWT 2.4) for client side validation and run into an issue.

Validation works fine. I want to use the Editor's built in capability to display errors (i.e ValueBoxEditorDecorator). However the EditorDriver interface only specifies setConstraintViolations(Iterable> violations); But the validate function from the BeanValidation returns a Set> and I can't cast from this to the type that is expected in the setConstraintViolations function.

The only workaround I found is creating a new Set and adding the ConstraintViolations to it.


Set<ConstraintViolation<MyProxy>> violations = validator.validate(myProxy,Default.class);
Set<ConstraintViolation<?>> violations2 = new HashSet<ConstraintViolation<?>>();
for (ConstraintViolation<StudyProxy>constraint:violations) {
    violations2.add(constraint);
}
if (!violations.isEmpty()) {
    driver.setConstraintViolations(violations2);
}
else {
  //proceed
}

I can this is related to this issue: http://code.google.com/p/google-web-toolkit/issues/detail?id=6270

Is there any better way to do that?

Thomas Broyer

unread,
Aug 28, 2012, 11:44:13 AM8/28/12
to google-we...@googlegroups.com
As suggested in the issue you link to:

@SuppressWarning("unchecked", "rawtypes")
Set<ConstraintViolation<?>> violations2 = (Set<ConstraintViolation<?>>) (Set) violations;

 

Ümit Seren

unread,
Aug 29, 2012, 4:33:50 AM8/29/12
to google-we...@googlegroups.com
Thanks!. The double cast does the trick
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/YJRSUeAf-nIJ.
>
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.

Alexandre Harvey-Tremblay

unread,
Oct 14, 2013, 4:39:21 PM10/14/13
to google-we...@googlegroups.com
I am using the same code as you, however my errors are not displayed on the ValueBoxEditorDecorator object. Do you have issues with your errors showing?
Reply all
Reply to author
Forward
0 new messages