The problem is caused by the reference to the
RemoteService which can't be instantiated at design time.
GWT.create(MyService.class) needs to create an instance of the class that should invoke the
RemoteService implementation on the application server. During design time the application server isn't running so this doesn't work.
In the Swing world, we would get around this by wrapping the instantiation of the
RemoteService with a call to
Beans.isDesignTime() (which is set to true at design time and false at runtime). GWT does not support
Beans.isDesignTime() (yet), so we have come up with our own alternative.
We've added support for a "
private static final boolean isDesignTime() {return false;}" method. We will then replace it with "
return true;" during class loading at design time (it will compile normally and be ignored at runtime). Give this a try:
- Code: Select all
public class LoginComposite extends Composite {
private final MyServiceAsync service;
public LoginComposite() {
if (!isDesignTime()) {
service = MyService.Util.getInstance();
} else {
service = null;
}
{
final FlexTable flexTable = new FlexTable();
initWidget(flexTable);
{
final Button button = new Button();
flexTable.setWidget(0, 0, button);
button.setText("New Button");
}
}
}
private static final boolean isDesignTime() {
return false;
}
}