Search code examples
gwtdependency-injectionguicegwt-gingwt-platform

Error binding view to presenter?


I'm getting this error when running GWT application:

java.lang.AssertionError: This UIObject's element is not set; you may be missing a call to either Composite.initWidget() or UIObject.setElement()

public class MainView extends Composite implements HeaderPresenter.MyView {
  // Code omitted
}

In the Gin ClientModule.java configure() function I have this code:

bindPresenter(HeaderPresenter.class, HeaderPresenter.MyView.class,
                MainView.class, HeaderPresenter.MyProxy.class);

In the view class the initWidget() is properly called and passed with a widget, what could be causing the error?


Solution

  • This error occurs when UIObject.setElement isn't called. If you are calling Composite.initWidget with a non-null widget, make sure that that widget is setting its own element correctly. If this is a standard GWT widget, it should be doing that, but otherwise it is possible that the widget passed to initWidget isn't set up correctly.