views:

233

answers:

2

Hi everyone,

I have a GWT application that uses RPC calls heavily. I would like to display a spinner icon whenever a call is in progress. It is easy enough to display the icon, but I want to do it seamlessly in one place so I don't have to explicitly hide and show the icon for each call.

I guess I am looking for something similar to jQuery's ajaxStart and ajaxStop events.

Has anyone done something like this before?

Cheers Tin

+1  A: 

Why don't you implement this behaviour in a concrete implementation of AsyncCallback and subclass all the AsyncCallbacks from this one. Alternatively you could use a decorator pattern where you use a regular AsyncCallback and decorate it with another one that shows/hides the popup.

Alternatively, if you use a Command Pattern, you could just add these events to your command pattern implementation and you can register a handler that shows/hides a popup every time a request is send/received.

David Nouls
I think decorator pattern is the best way to implement this. But I would like to see this as a standard thing provided by GWT in some later version.
sbidwai
I guess I would need both. An AsyncCallback base class that handles the stopping of the spinner as well as a decorator class for each async interface. The problem is, I have a lot of different async interfaces and it would be a mess to try and wrap all of them seperately. Any ideas on how I could do it generically?In standard java, AOP would solve this kind of thing but I'm not sure whether there is a GWT equivalent.
triggerNZ
+1  A: 

There are some solutions on this related question.

David Tinker
Thank you. This helps
triggerNZ