如何等待来自其他演示者的RPC?

时间:2014-01-10 11:09:31

标签: gwt block gwt-rpc gwt-platform presenter

我使用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();

因此,在成功加载所有内容之前,用户无法点击任何内容。 当来自rpc的onSucess()被调用时,Panel将被隐藏。

My 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数据成功加载之前被调用?

0 个答案:

没有答案
相关问题