Reputation: 35276
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?
Upvotes: 1
Views: 2246
Reputation: 12212
This is how I create a Composite
that I will use later in a View.
public class MyCustomBox extends Composite {
private static MyCustomBoxUiBinder uiBinder = GWT.create(MyCustomBoxUiBinder.class);
interface MyCustomBoxUiBinder extends UiBinder<Widget, MyCustomBox> {
}
public MyCustomBox() {
initWidget(uiBinder.createAndBindUi(this));
}
}
Upvotes: 3
Reputation: 18331
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.
Upvotes: 3