-
31 May 2012 4:15 AM #1
PagingToolBar buttons not responsive after onBeforeLoad setCancelled
PagingToolBar buttons not responsive after onBeforeLoad setCancelled
I've created a Grid with a PagingToolBar. Everything is configured to use a PagingLoader to load data remotely from the server.
In my special case I have to check whether it is acceptable to jump to another page or not.
Therefore I registered a LoadHandler at the PagingLoader to catch the event onBeforeLoad and cancel it if necessary.
Code:pagingLoader.addLoaderHandler(new LoaderHandler() { @Override public void onBeforeLoad(BeforeLoadEvent<FilterPagingLoadConfig> event) { boolean decision = Window.confirm("Cancel loading?"); event.setCancelled(decision); } }
After having reset the LoadMask everything seems to be fine except that the PagingToolBar Buttons are not responsive anymore. All clicks are simply ignored.
After having done some research in the PagingToolBar class I've found out that the loading flag is not properly reset when the event was cancelled. This flag is checked each time a button is clicked and as not reset when the load event was cancelled all button clicks are ignored.
As this flag cannot be set outside of the PagingToolBar class there is no way to fix this directly.
So this must be fixed inside the PagingToolBar class itself:
Code:private LoaderHandler<PagingLoadConfig, ?> handler = new LoaderHandler<PagingLoadConfig, PagingLoadResult<?>>() { @Override public void onBeforeLoad(final BeforeLoadEvent<PagingLoadConfig> event) { loading = true; savedEnableState = isEnabled(); setEnabled(false); refresh.setIcon(appearance.loading()); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { if (event.isCancelled()) { refresh.setIcon(appearance.refresh()); setEnabled(savedEnableState); loading = false; // <-- THIS STATEMENT HAS TO BE ADDED } } }); } @Override public void onLoad(LoadEvent<PagingLoadConfig, PagingLoadResult<?>> event) { refresh.setIcon(appearance.refresh()); setEnabled(savedEnableState); PagingToolBar.this.onLoad(event); loading = false; } @Override public void onLoadException(LoadExceptionEvent<PagingLoadConfig> event) { refresh.setIcon(appearance.refresh()); setEnabled(savedEnableState); loading = false; } };
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote