I'm implementing MVP in my first GWT app using the recommended API from their docs, and admittedly, am doing some cargo cult programming while scrambling to learn/understand the API:
public class DefaultSignInView extends Composite implements SignInView {
private static DefaultSignInViewUiBinder uiBinder = GWT
.create(DefaultSignInViewUiBinder.class);
public DefaultSignInView() {
// ERROR: The method initWidget(Widget) in the type Composite is not applicable
// for the arguments (DivElement)
initWidget(uiBinder.createAndBindUi(this));
}
// Extends the UiBinder interface for this particular view.
interface DefaultSignInViewUiBinder extends UiBinder<DivElement, DefaultSignInView> {
// No-op.
}
}
In the above code snippet, the call to initWidget
is a syntax/compiler error:
The method initWidget(Widget) in the type Composite is not applicable for the arguments (DivElement).
Now in the documentation (linked above) they show that you should extend UiBinder
without the generic arguments. But I've also seen examples that use the generics, and again, cargo culting it, I borrowed from another example that used DivElement
as the first argument. So, a few questions:
- Why am I getting this syntax error?
- What can I change
DivElement
to (or what else would I have to change) to correct it, besides removing the generic arguments? And if the generic arguments are deprecated or are truly no longer used, can someone explain why? In that case I'll just@SuppressWarnings
. - Would someone provide a clear, layman's explanation of what the code is doing here? I hate cargo culting my code.
I sincerely think you are looking in the wrong place. Try this here. Most of it is explained in the docs, still i will try to highlight a few points,
I am adding a my sample code below
SampleUI ui-binder
SampleUI java