本文参考:http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/7ed0d179b89fa062/aaeb5391a760adef?lnk=gst&q=indicator+AsyncCallback&rnum=1#aaeb5391a760adef
大部分代码也是参考文中的。
package com.javaeye.dengyin2000.truck.client.server;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
public abstract class AsyncCallbackWithStatus implements AsyncCallback {
private static LoadingIndicator loadingIndicator;
public static final void setLoadingIndicator(LoadingIndicator indicator) {
loadingIndicator = indicator;
}
public AsyncCallbackWithStatus() {
setLoading(true);
}
public final void onSuccess(Object object) {
setLoading(false);
onSuccessInternal(object);
}
public final void onFailure(Throwable throwable) {
setLoading(false);
onFailureInternal(throwable);
}
protected abstract void onSuccessInternal(Object object);
protected void onFailureInternal(Throwable throwable){
Window.alert("服务器没有响应,请稍后再试!");
}
private void setLoading(boolean isLoading) {
if (null != loadingIndicator) {
if (isLoading) {
loadingIndicator.show();
} else {
loadingIndicator.hide();
}
}
}
interface LoadingIndicator {
void show();
void hide();
}
}
package com.javaeye.dengyin2000.truck.client.server;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.WindowResizeListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.PopupPanel;
import com.javaeye.dengyin2000.truck.client.server.AsyncCallbackWithStatus.LoadingIndicator;
public class LoadingStatus implements LoadingIndicator, WindowResizeListener {
private PopupPanel popup;
public LoadingStatus() {
popup = new PopupPanel();
popup.add(new HTML("<div style='background-color: red;'> Loading, please wait...</div>"));
placeIndicator();
Window.addWindowResizeListener(this);
// set the style name for greater control over the
}
public void show() {
popup.show();
}
public void hide() {
popup.hide();
}
private void placeIndicator(){
popup.setPopupPosition(Window.getClientWidth() - 120, 10);
}
public void onWindowResized(int width, int height) {
placeIndicator();
}
}
在你的EntryPoint中装配好你的indicator
private void prepareLoadingIndicator(){
LoadingStatus status = new LoadingStatus();
AsyncCallbackWithStatus.setLoadingIndicator(status);
}
这样调用。
private void populateAndReadEnterprisesInfo(){
GWTRPCServiceLocator.getUserService().getEnterprisesInfo(new AsyncCallbackWithStatus(){
protected void onSuccessInternal(Object object) {
EnterprisesInfoGTO gto = (EnterprisesInfoGTO) object;
enterpriseName.setText(gto.getEnterprisesName());
contactName.setText(gto.getContactName());
contactTel.setText(gto.getContactTel());
contactFax.setText(gto.getContactFax());
contactAddress.setText(gto.getContactAddress());
zipCode.setText(gto.getZipCode());
email.setText(gto.getEmail());
siteAddress.setText(gto.getSiteAddress());
}
});
}
分享到:
相关推荐
gwt 练习gwt 练习gwt 练习gwt 练习
EXT-GWT2.0.1+API+DOC gwtdesigner Gwt-Ext基础-中级-进阶 GWT快速开发 GWT入门 GWT中文教程
fwefwefwGWT工具GWT工具GWT工具GWT工具GWT工具GWT工具
Gwt中文手册,GWt入门Gwt中文手册,GWt入门Gwt中文手册,GWt入门
gwt 入门,是你开始学习gwt的大道 安装之后的目录结构为: C:\程序开发\Java\gwt-windows-1.4.59 doc(文档目录,开发文档和Java API文档) samples(示例代码目录,非常有名的KitchenSink示例代码即在此目录中)...
很好的资源,在这边分享下,提供给想要寻找GWT资源的兄弟姐妹们 如果哪位兄弟有好的资源不要忘了分享啊
GWT(Google Web Toolkit) 是 Google 最近推出的一个开发 Ajax 应用的框架,它支持用 Java 开发和调试 Ajax 应用,本文主要介绍如何利用 GWT 进行 Ajax 的开发。 Ajax技术是当前开发web应用的非常热门的技术,也是Web...
Gwt google web toolkit 网页开发工具,主要是把java自动转换成javaScript,能够在客户端响应,不存在卡机等待现象。适合于一些需要服务响应很久的网站程序开发
smartgwt最新版本GWT的DEMO 谷歌web工具箱实例
2. Hello GWT 3. 模块 4. JSNI 5. 在GWT中使用XML 6. GWT控件详解 7. 使用GWT控件 8. GWT-RPC 9. Ext GWT 10. (实战)俄罗斯方块游戏 11. (实战)费用申请审批流程 12. GWT与Flex整合 13. 图片缓存 CSS Sprite 14. ...
用Maven创建GWT_SmartGWT项目,从而可利用Maven进行管理,以及持续集成。
GWT的eclipse4.4离线开发插件,国内现在没有
最新火狐浏览器GWT开发插件,离线安装。不用在线等待!
基本概念及GWT结构及命令,开发等的介绍
GWT学习时的一些小例子,和大家分享,GWT学习时的一些小例子,和大家分享
gwt-2.1.0
gwt学习资料 java gwt相关学习网站 gwt图解 gwt教学 gwt安装部署 步骤流程
这个文件是关于GWT开发的,属于入门级别的,GWT新手可以下载了看看。
GWT-Ext 控件演示 GWT-Ext 控件演示
smartgwt-1.3smartgwt-1.3smartgwt-1.3smartgwt-1.3smartgwt-1.3