Synchronous call

Showing 1-5 of 5 messages
Synchronous call oualaa hani 4/24/08 1:45 AM

Please I want know how cn do synchronous call

Thank you.
Re: Synchronous call Sebastien Chassande-barrioz 4/24/08 8:43 PM

Your question is a bit ambiguous. So I answer to both understanding :

1/ if you talk about locking (synchronized)
The browser do not use several thread for executing the Javascript.
Then you do not have problem of synchronization.
Simply use a local variables to remember which calls are finished.

2/ if you want to do a synchronous call to the server
With GWT all calls to a service on server are asynchronous. Therefore
to do a task after the end of call you have to write the code in the
callback. Therefore your code is split in two parts :

private void m1() {
  // first part of code
  // call to the server
  MyService.Util.getInstance().myRemoteMethod("hello world", new
AsyncCallBack() {
      public void onSuccess(Object result) {
          //second part of the code executed only after the remote
      public void onFailure(Throwable problem) {
          //second part of the code executed only after the remote
  } );
  //in most case do nothing here because you do not know when it is
executed with regards to the
} //end of m1

The code corresponding to the onSuccess (or onFailure) can also be
written into a separated method in order to the readability of your
code. Your code is therefore divided in two method. I advice you to
read the GWT doc :

Re: Synchronous call oualaa hani 4/24/08 8:52 PM

Thank you for your answer.

All what I wanted to know is, each time we want communicate with server we have to do asynchronous call.

Re: Synchronous call Jason Essington 4/29/08 8:06 AM
It is possible to perform Synchronous XMLHTTP Requests, BUT due to the  
asynchronous nature of html, it is a bad idea (tm).

As a result, GWT does not make any effort to allow you to do it  
easily. You'd have to write your own extension of the RequestBuilder  
that allows Synchronous requests.

The problem with Synchronous requests is that they tend to block the  
browser waiting for a response, giving your application the appearance  
of being locked up. This is particularly bad application design. You  
have no control of the client machine or the network between it and  
your servers, and as such can't even dictate how long your application  
is going to appear locked.

So, the best idea is to simply use the asynchronous method and  
continue execution via the callbacks provided. You will end up with a  
much better user experience, and a more professional appearing  


Re: Synchronous call Alyxandor 4/29/08 8:42 AM
Aye aye!  I second asynchronicity! If, for some reason, you want pseudo-synchronicity, just add a fulll screen, position:absolute;left:0;top:0;width:100%;height:100%;opacity:0.77;filter:Alpha(77);z-index:777777; div when the request is sent {maybe even include a tasty loading or sending message}, and remove the div when the response returns.

I use this method when the user posts a new entry, and I want my server to make sure it's properly saved before the user starts playing with certain parts of the app...  Like, editing their saved documents... Because I don't want anybody to start requesting a file I haven't saved yet...--
"He whose desires are drawn toward knowledge in every form will be absorbed in the pleasures of the soul, and will hardly feel bodily pleasure --I mean, if he be a true philosopher and not a sham one." - Plato
"Wise Words Whispered Without Will Won't Wake Worlds" - Alyxandor Artistocles