gwt AsyncCallback 的方法调用

tongshushan tongshushan 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

如下面一段代码
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方法?
...全文

相关推荐

评论 10
收藏 已收藏
分享
返回顶部
tongshushan
Web 开发 81,108 成员 341,721 内容