English 中文(简体)
Is it possible to seamlessly display an ajax spinner for every GWT RPC call?
原标题:

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

问题回答

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.

In response to comments that suggest a Decorator is not enough.

abstract class AbstractAsyncCallback <T> implements AsyncCallaback <T>
{
 public AbstractAsyncCallback ()
 {
  Foo.showIcon();
 }

 @Override public void success (T t)
 {
  doSuccess(t);
  Foo.hideIcon();
 }

 @Override public void failure ()
 {
  doFailure();
  Foo.hideIcon();
 }

 public abstract void doSuccess (T t);

 public abstract void doFailure (T t);
};




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签