I want to check the data at the time the page got loaded. I also want to put the loading indicator popup when checking data so that user will know that the page is loading data.
Look at this code:
String item="";
@Override
public void prepareFromRequest(PlaceRequest request){
super.prepareFromRequest(request);
item=request.getParameter("item", "");
addToPopupSlot(loadingPresenter);
GetData action=new GetData(item);
dispatchAsync.execute(action, getDataCallback);
}
private AsyncCallback<GetDataResult> getDataCallback=new AsyncCallback<GetDataResult>(){
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
loadingPresenter.hide();
}
@Override
public void onSuccess(GetDataResult result) {
// TODO Auto-generated method stub
loadingPresenter.hide();
//code to show data here
}
}
OK, this code works fine in IE and in Firefox, but not ok in Chrome. That is:
In Chrome, after refreshing the page, the indicator did not hide though all data was showed correctly. In IE & Firefox the the indicator got hided properly.
I think there something wrong with Chrome somehow they can't call the loadingPresenter.hide();
What should I do? I don't think I should remove the loadingPresenter
cos the getData
method also was called when user clicking a button, so i need it to indicate the data is loading. But if i uses loadingPresenter
then i can't run in Chrome.
So what should I do?
I solved the problem, just put the callingMethod inside onReset, then it will be fine cos prepareFromRequest was called too early that some how other widget has not been bound yet & that causing the problem. This should work in all browser.
String item="";
@Override
public void prepareFromRequest(PlaceRequest request){
super.prepareFromRequest(request);
item=request.getParameter("item", "");
}
@Override
public voi onReset{
super.onReset();
addToPopupSlot(loadingPresenter);
GetData action=new GetData(item);
dispatchAsync.execute(action, getDataCallback);
}