1

Is it possible to make a gwt rpc blocking? i.e. the application blocks until a response is received from the server

2
  • You might want to add a bit more info. Blocking calls in a javascript application (which is what GWT ultimately boils down to) are almost never a good idea. You need to have really good reasons to do this, and most things can be solved using asynchronous calls (e.g. set a flag and don't execute certain things if it's set).
    – tdammers
    Jan 5, 2011 at 7:12
  • I have an application which it can completly load if the user details are obtained from the server, so when the app starts, I make an RPC and then the result from the rpc are use to feed in the app, I cannot continue until the data from the rpc is obtained so I want to make the rpc blocking so that only when the rpc completes, then the application can start
    – Noor
    Jan 5, 2011 at 7:27

3 Answers 3

4

As far as I know there is no gwt rpc blocking because it is opposite idea to the asynchronous callback.

But you can use these two methods

  1. Timer. Count timer and check that there is any return object that is not null and stop and cancel timer and continue your job. If timer is active don't do other job. This is very very inefficient way. Lack of OO design pattern and too many if-else-if statements
  2. Call Rpc and do all actions in onSuccess() method. It guarantees that your method is finished and successfully finished then continue to other methods.

My advise is 2nd one (onSuccess). I want to mention again that blocking is never a good idea

1

Well, synchronus rpc calls are called as evils by GWT designers. They do have very strong arguments... But you can succeed synchronous rpc by means of hacks..Here is one of them, http://code.google.com/p/google-web-toolkit/issues/detail?id=4898

0

The most simple solution that came to my mind would be to "block" your application from the point where the Asynchronous call starts till the filling is completed, which would be at the end of the onSuccess() method.

By blocking I mean just to show some animated loading gif in the middle of the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.