gwt AsyncCallback 的方法调用
如下面一段代码
public class MyApplication implements EntryPoint {
public void onModuleLoad() {
// define the service you want to call
MyServiceAsync svc = (MyServiceAsync) GWT.create(MyService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) svc;
String svUrl = GWT.getModuleBaseURL() + "myService";
endpoint.setServiceEntryPoint(svUrl);
// define a handler for what to do when the
// service returns a result
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
RootPanel.get().add(new HTML(result.toString()));
}
public void onFailure(Throwable ex) {
RootPanel.get().add(new HTML(ex.toString()));
}
};
// execute the service
svc.myMethod(1, callback);
}
}
请问什么时候调用onSuccess,和onFailure方法?