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方法?
...全文
相关推荐
GWT通信机制初探
你可以创建一个`RequestBuilder`实例,设置其方法(GET或POST)、URL以及请求头,然后调用`send()`方法发送请求。
Ext + Gwt + Struts2.0开发5
- 异步接口:在能够调用服务之前,需要基于同步接口创建客户端的异步接口。由于异步方法调用的性质,调用者需要传递一个AsyncCallback对象。这个回调对象用于在异步调用完成后通知调用者。
async-api:Java和GWT应用程序的异步实用程序
当你调用远程服务时,可以传递一个`AsyncCallback`实例,当服务调用成功或失败时,回调方法会被调用。2.
gwt服务端及部署学习
在异步服务接口`GetTimeServiceAsync`中,添加`void getTime(AsyncCallback callback)`方法,该方法用于异步调用服务器,获取时间后通过回调函数传递结果
GWT-API 帮助文档
**RPC服务**:介绍GWT的远程过程调用(RPC)机制,用于客户端与服务器端的数据交换。6. **异步编程**:讨论GWT的异步回调机制,如AsyncCallback,以及如何处理网络请求。7.


Web 开发
