Export to GitHub

google-web-toolkit - issue #6270

RFE: relax BaseEditorDriver setViolations/setConstraintViolations to take Iterable<? extends X> instead of Iterable<X>


Posted on Apr 20, 2011 by Swift Rhino

Found in GWT Release (e.g. 1.5.3, 1.6 RC): trunk @ r9848 but this is true since 2.1 (on RequestFactoryEditorDriver)

Detailed description (please be as specific as possible): setViolations and setConstraintViolations take Iterable<X> arguments, which makes it impossible to give an Iterable<SomethingThatExtendsX> without an unsafe cast (double cast actually: to the Iterable raw type and then to Iterable<X>).

Our use case: when saving entities (using RequestFactory), we're doing validation in the background on the server (i.e. we store potentially invalid objects and then validate them, instead of using RequestFactory's built-in "validation as a precondition" feature). When editing an entity, we retrieve both the entity and its associated violations from the server. This means we have an interface "ViolationProxy extends ValueProxy, Violation" and we retrieve a List<ViolationProxy> (we must declare it exactly that way for RequestFactory to correctly "map" our server-side entities to the client-side proxy). The issue: we cannot give this List<ViolationProxy> to our EditorDriver's setViolations without an unsafe cast, because we have an Iterable<ViolationProxy> and setViolations expects an Iterable<Violation> rather than an Iterable<? extends Violation>.

Comment #1

Posted on Jun 2, 2013 by Massive Cat

@Thomas what should be do here?

Comment #2

Posted on Jun 3, 2013 by Swift Rhino

I should contribute a patch :-)

This is a breaking change but I don't think many people have implemented their own EditorDriver (or even mock) so I think it's safe.

Comment #3

Posted on Jun 10, 2015 by Massive Cat

Issue tracked moved to github, see https://github.com/gwtproject/gwt/issues

Status: MovedToGithub