Re: Synchronous call | Sebastien | 4/24/08 8:43 PM | Hi,
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 call } public void onFailure(Throwable problem) { //second part of the code executed only after the remote call } } ); //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 : http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.html Regards, Seb On Apr 24, 10:45 am, "oualaa hani" <oualaa....@gmail.com> wrote: > Hi, > > Please I want know how cn do synchronous call > > Thank you. |
oualaa hani | 4/24/08 1:45 AM | <This message has been deleted.> | |
oualaa hani | 4/24/08 8:52 PM | <This message has been deleted.> | |
Jason Essington | 4/29/08 8:06 AM | <This message has been deleted.> | |
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... On Tue, Apr 29, 2008 at 9:06 AM, Jason Essington <jason.e...@gmail.com> wrote:
-- "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 |