【问题标题】:Loading indicator between two screens GWT两个屏幕之间的加载指示器 GWT
【发布时间】:2013-07-24 12:12:44
【问题描述】:

我在 GWT 的主页中有一个按钮。单击此按钮时,屏幕将更新为新的 GWT 元素,并且无需发送 RPC 调用。但这两个屏幕之间,有很长的时间。所以我想为此制作一个加载指示器(如动画 gif)。

我该怎么做?

【问题讨论】:

  • 在尝试解决您的问题之前,我会开始挖掘并了解为什么这很慢。因为显示加载指示器可能与显示第二个屏幕一样慢。另外,不要在 DevMode 下判断性能。
  • 问题是阻塞应用程序大约 4 秒!!!
  • 但是你说你不做 RPC(我更广泛地理解为“没有与服务器通信,等待响应”),所以 what 块4 秒?
  • 谢谢托马斯。如您所说,在生产模式下不会出现问题。

标签: gwt


【解决方案1】:

GWT 类 PopupPanel 有一个可选的“玻璃面板”,用于阻止与下方页面的交互。

final PopupPanel popup = new PopupPanel(false, true); // Create a modal dialog box that will not auto-hide
popup.add(new Label("Please wait"));
popup.setGlassEnabled(true); // Enable the glass panel
popup.center(); // Center the popup and make it visible

【讨论】:

    【解决方案2】:

    嗨,我已经实现了他。我在加载另一个屏幕之前附上了加载图像。下面是代码:

    public class Utility {
    
    private static LoadingDlg dlg=new LoadingDlg(false, true);
    
    public static void showLoading(){
        if(count <= 0){
    
    
            dlg.center();
            count = 1;
        }
        else
        count++;
    
    }
    public static void hideLoading(){
        if(count <= 1){
            dlg.hide();     
            count = 0;
        }
        else{
        count--;
        }
    }
    
    }
    
    
    
    
    
    
    public LoadingDlg(boolean autoHide, boolean modal) {
        super(autoHide, modal);
        this.setGlassEnabled(true);
        this.setTitle("Press Esc Key to Hide.");
        this.setGlassStyleName("loadingstyle");     
        FlowPanel hp=new FlowPanel();
        hp.setStyleName("loadingImg");
        this.getElement().getStyle().setZIndex(500);
        this.setWidget(hp);
    
    }
    

    相同的CSS:

    .loadingstyle{
    display: block !important;   
    visibility: visible !important;    
    z-index: 500 !important;
    background-color: #000;
    opacity: 0.3;
    filter: alpha(opacity=30);
    

    }

       .loadingImg{
    background-image:url(images/loadingimage.gif);
    background-repeat:no-repeat;
    display: block; 
    height: 24px;
    width: 161px;
    

    } .

    您必须在您的图像文件夹中添加一个 loadingimage.gif 并相应地调用 showLoading 和 hideLoading 函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      相关资源
      最近更新 更多