GWT make RPC blocking
Is 开发者_JAVA技巧it possible to make a gwt rpc blocking? i.e. the application blocks until a response is received from the server
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
- 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
- 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
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
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.
精彩评论