Export to GitHub

google-web-toolkit - issue #6323

Cannot use class with generic types and @UIHandler with ValueChangeEvent<?> event


Posted on May 7, 2011 by Quick Horse

Found in GWT Release (e.g. 1.5.3, 1.6 RC):

  • Found in 2.2.0
  • Still present in 2.3.0

Encountered on OS / Browser (e.g. WinXP, IE6-7, FF3):

  • Win7

Detailed description (please be as specific as possible):

I can easily reproduce the encountered problem with HandlerDemo.java (here: http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/uibinder/test/client/HandlerDemo.java)

1) Use HandlerDemo.java

1) Modify the declaration by creating a generic type declaration as following:

e.g. replace public class HandlerDemo extends Composite by public class HandlerDemo<T> extends Composite

2) Use this class e.g. RootPanel.get().add(new HandlerDemo<String>());

3) Run the dev mode

You should get these errors:

  • DEBUG: Rebinding com.mySampleApplication.client.HandlerDemo.MyUiBinder. ERROR: Deferred binding failed for 'com.mySampleApplication.client.HandlerDemo.MyUiBinder'; expect subsequent failures. DEBUG: Invoking generator com.google.gwt.uibinder.rebind.UiBinderGenerator. WARN: The method 'getAssociatedType()' in 'ValueChangeEvent' does not return Type<? extends EventHandler>.. ERROR: Parameter 'ValueChangeEvent' is not an event (subclass of GwtEvent)..

Workaround if you have one:

1) Do not use @UIHandler with a typed event if the class to bind with template is typed and add manually ValueChangeHandler

e.g.:

myCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) { // do something... } });

Attachments

Comment #1

Posted on Nov 18, 2011 by Happy Lion

Still present in GWT 2.4. Reproducible on Red Hat Linux x64 / FF7.

Attaching updated example with non-relevant stuff removed.

Attachments

Comment #2

Posted on Jul 7, 2012 by Helpful Wombat

Still present in 2.5-rc1

Comment #3

Posted on Jul 8, 2012 by Swift Rhino

The issue is that the UiBinder is declared with the raw type, so the generator subsequently only sees raw types down until ValueChangeEvent#getAssociatedType returning a raw GwtEvent.Type.

Declaring the UiBinder with a wildcard type is enough to make it compile. I.e.: interface MyUiBinder extends UiBinder> {} instead of: interface MyUiBinder extends UiBinder {}

Comment #4

Posted on May 6, 2013 by Grumpy Bear

Comment deleted

Comment #5

Posted on May 6, 2013 by Grumpy Bear

Hi, is this issue still present in current GWT version?

Comment #6

Posted on Oct 3, 2013 by Grumpy Ox

This seems to be still an issue in 2.5.1 I have the Ui Binder declared with a wildcard type but of course I need to have my ValueChangeEvent declared with the wildcard as well and then downcast it to the type I want. It seems that it defeats the purpose.

Status: NotPlanned