Im using gwt-platform and I have 2 Presenters ( MainpagePresenter and SecondpagePresenter). MainpagePresenter is my DefaultPlace. So, onModuleLoad I am starting to load data from the server part with rpc and saving my data into the client cache. I implemented a PopupPanel to show a loading screen like this:
PopupPanel loadingPanel = new PopupPanel(false, true);
this.loadingPanel.add(new Label("loading..."));
this.loadingPanel.center();
this.loadingPanel.show();
So the user can't click on anything before everything is loaded sucessfully.
The Panel will be hidden when onSucess()
from the rpc is called.
My SecondpagePresenter gets the saved data from the cache onReset()
.
@Override
protected void onReset()
{
super.onReset();
this.data = (Data) this.cache.get("Data");
}
Everything works fine, but when I am browsing the second page and do a browser refresh, the code of SecondpagePresenter will still be called before my data is received.
The only solution I found so far is to implement a while loop like this:
while(cache.get("data") != null)
{
Window.alert("loading");
}
This prevents the code to continue but the user has to click on an "OK"-Button.
So my questions is: Is there a way to block the code from SecondpagePresenter to get called before the data from my MainpagePresenter is loaded successfully?