我使用 gwt-platform,我有 2 个演示者(MainpagePresenter 和 SecondpagePresenter)。MainpagePresenter 是我的 DefaultPlace。因此,onModuleLoad 我开始使用 rpc 从服务器部分加载数据并将我的数据保存到客户端缓存中。我实现了一个 PopupPanel 来显示这样的加载屏幕:
PopupPanel loadingPanel = new PopupPanel(false, true);
this.loadingPanel.add(new Label("loading..."));
this.loadingPanel.center();
this.loadingPanel.show();
因此,在成功加载所有内容之前,用户无法单击任何内容。当onSucess()
从 rpc 被调用时,面板将被隐藏。
我的 SecondpagePresenter 从缓存中获取保存的数据onReset()
。
@Override
protected void onReset()
{
super.onReset();
this.data = (Data) this.cache.get("Data");
}
一切正常,但是当我浏览第二页并刷新浏览器时,在收到我的数据之前仍会调用 SecondpagePresenter 的代码。
到目前为止,我发现的唯一解决方案是实现这样的 while 循环:
while(cache.get("data") != null)
{
Window.alert("loading");
}
这会阻止代码继续,但用户必须单击“确定”按钮。
所以我的问题是:有没有办法阻止 SecondpagePresenter 的代码在我的 MainpagePresenter 的数据成功加载之前被调用?