Re: Stop further execution till rpc completes
There have been lots of people ask this question here. The advice you will get is: (1) Don't try to do it like that. It's evil. (2) Embrace asynchrony. Here's what your code should look like: // some code here 1 myservice.rpcCall(args, new AsyncCallbackFoo { public void onFailure(Throwable t) {} public void onSuccess(Foo foo) { // some code here 2 } }); Paul On 01/08/11 16:29, Deepak Singh wrote: Hi, I have a requirement, // some code here 1 RPC call // some code here 2 I want to stop any further execution after rpc call till rpc completes. When RPC call is finished, the control should automatically start executing next line of code. I tried Scheduler class but could get into success. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Stop further execution till rpc completes
I am making 2 seperate RPC calls. Whichever is finished first, i would add RootPanel.get(id).add(widget) into onSuccess. I can not add same widgets two times in both onSuccess(). So i am out of mind how to resolve this. Any logic pls. On Mon, Aug 1, 2011 at 9:08 PM, Jens jens.nehlme...@gmail.com wrote: Its not possible to stop execution as RPC requests are async. The only thing you can do is to put your code that has to wait into the onSuccess method of your RPC call. -- J. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/hgRZHjACARUJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Stop further execution till rpc completes
I think you'll have to do something like this: public class MyEntryPoin implements EntryPoint { private boolean alreadyAddedWidget; public void onModuleLoad() { alreadyAddedWidget = true; MyService service = GWT.create(MyService.class); service.someCall(args, new AsyncCallbackFoo() { public void onFailure(Throwable caught) {} public void onSuccess(Foo result) { if (alreadyAddedWidget) return; alreadyAddedWidget = true; RootPanel.get().add(...); } } service.anotherCall(args, new AsyncCallbackBar() { public void onFailure(Throwable caught) {} public void onSuccess(Bar result) { if (alreadyAddedWidget) return; alreadyAddedWidget = true; RootPanel.get().add(...); } } } } On Mon, Aug 1, 2011 at 1:23 PM, Deepak Singh deepaksingh...@gmail.comwrote: I am making 2 seperate RPC calls. Whichever is finished first, i would add RootPanel.get(id).add(widget) into onSuccess. I can not add same widgets two times in both onSuccess(). So i am out of mind how to resolve this. Any logic pls. On Mon, Aug 1, 2011 at 9:08 PM, Jens jens.nehlme...@gmail.com wrote: Its not possible to stop execution as RPC requests are async. The only thing you can do is to put your code that has to wait into the onSuccess method of your RPC call. -- J. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/hgRZHjACARUJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- Magno Machado Paulo http://blog.magnomachado.com.br http://code.google.com/p/emballo/ -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Stop further execution till rpc completes
public void onModuleLoad() { alreadyAddedWidget = true; Sorry, it should be set to false here On Mon, Aug 1, 2011 at 2:13 PM, Magno Machado magn...@gmail.com wrote: I think you'll have to do something like this: public class MyEntryPoin implements EntryPoint { private boolean alreadyAddedWidget; public void onModuleLoad() { alreadyAddedWidget = true; MyService service = GWT.create(MyService.class); service.someCall(args, new AsyncCallbackFoo() { public void onFailure(Throwable caught) {} public void onSuccess(Foo result) { if (alreadyAddedWidget) return; alreadyAddedWidget = true; RootPanel.get().add(...); } } service.anotherCall(args, new AsyncCallbackBar() { public void onFailure(Throwable caught) {} public void onSuccess(Bar result) { if (alreadyAddedWidget) return; alreadyAddedWidget = true; RootPanel.get().add(...); } } } } On Mon, Aug 1, 2011 at 1:23 PM, Deepak Singh deepaksingh...@gmail.comwrote: I am making 2 seperate RPC calls. Whichever is finished first, i would add RootPanel.get(id).add(widget) into onSuccess. I can not add same widgets two times in both onSuccess(). So i am out of mind how to resolve this. Any logic pls. On Mon, Aug 1, 2011 at 9:08 PM, Jens jens.nehlme...@gmail.com wrote: Its not possible to stop execution as RPC requests are async. The only thing you can do is to put your code that has to wait into the onSuccess method of your RPC call. -- J. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/hgRZHjACARUJ. To post to this group, send email to google-web-toolkit@googlegroups.com . To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- Magno Machado Paulo http://blog.magnomachado.com.br http://code.google.com/p/emballo/ -- Magno Machado Paulo http://blog.magnomachado.com.br http://code.google.com/p/emballo/ -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Stop further execution till rpc completes
How about: if (!RootPanel.get(id).contains(widget)) { RootPanel.get(id).add(widget); Because of the nature of javascript and web browsers the above call is inherently thread safe. HTH Alan On 8/1/2011 9:23 AM, Deepak Singh wrote: I am making 2 seperate RPC calls. Whichever is finished first, i would add RootPanel.get(id).add(widget) into onSuccess. I can not add same widgets two times in both onSuccess(). So i am out of mind how to resolve this. Any logic pls. On Mon, Aug 1, 2011 at 9:08 PM, Jens jens.nehlme...@gmail.com mailto:jens.nehlme...@gmail.com wrote: Its not possible to stop execution as RPC requests are async. The only thing you can do is to put your code that has to wait into the onSuccess method of your RPC call. -- J. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/hgRZHjACARUJ. To post to this group, send email to google-web-toolkit@googlegroups.com mailto:google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com mailto:google-web-toolkit%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Stop further execution till rpc completes
There is no contains(widget) available like RootPanel.get(id).contains( widget). On Mon, Aug 1, 2011 at 10:48 PM, Alan Chaney a...@mechnicality.com wrote: How about: if (!RootPanel.get(id).contains(widget)) { RootPanel.get(id).add(widget); Because of the nature of javascript and web browsers the above call is inherently thread safe. HTH Alan On 8/1/2011 9:23 AM, Deepak Singh wrote: I am making 2 seperate RPC calls. Whichever is finished first, i would add RootPanel.get(id).add(widget) into onSuccess. I can not add same widgets two times in both onSuccess(). So i am out of mind how to resolve this. Any logic pls. On Mon, Aug 1, 2011 at 9:08 PM, Jens jens.nehlme...@gmail.com wrote: Its not possible to stop execution as RPC requests are async. The only thing you can do is to put your code that has to wait into the onSuccess method of your RPC call. -- J. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/hgRZHjACARUJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Stop further execution till rpc completes
True its WidgetCollection that has a 'contains' method but a RootPanel.get returns a RootPanel object which is a sub-class of ComplexPanel. ComplexPanel has a getWidgetIndex methods which return -1 for getWidgetIndex(Widget) and null for getWidgetIndex(HasWidget) when the requested object isn't in the widget list. You can derive your own 'contains' logic from the above. Its purely a matter of style, but I'd personally prefer to avoid having extra state flags to manipulate and would rather use state that's already in the data of the object in question. Alan On 8/1/2011 11:51 AM, Deepak Singh wrote: There is no contains(widget) available like RootPanel.get(id).contains(widget). On Mon, Aug 1, 2011 at 10:48 PM, Alan Chaney a...@mechnicality.com mailto:a...@mechnicality.com wrote: How about: if (!RootPanel.get(id).contains(widget)) { RootPanel.get(id).add(widget); Because of the nature of javascript and web browsers the above call is inherently thread safe. HTH Alan On 8/1/2011 9:23 AM, Deepak Singh wrote: I am making 2 seperate RPC calls. Whichever is finished first, i would add RootPanel.get(id).add(widget) into onSuccess. I can not add same widgets two times in both onSuccess(). So i am out of mind how to resolve this. Any logic pls. On Mon, Aug 1, 2011 at 9:08 PM, Jens jens.nehlme...@gmail.com mailto:jens.nehlme...@gmail.com wrote: Its not possible to stop execution as RPC requests are async. The only thing you can do is to put your code that has to wait into the onSuccess method of your RPC call. -- J. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/hgRZHjACARUJ. To post to this group, send email to google-web-toolkit@googlegroups.com mailto:google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com mailto:google-web-toolkit%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com mailto:google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com mailto:google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com mailto:google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com mailto:google-web-toolkit%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Stop further execution till rpc completes
You could always do the following boolean alreadyAdded = false; void addWidget(Widget widget) { if (!alreadyAdded) { alreadyAdded = true; RootPanel.get().add(widget); } } and then call addWidget() in each onSuccess(); first caller wins. On Aug 1, 12:23 pm, Deepak Singh deepaksingh...@gmail.com wrote: I am making 2 seperate RPC calls. Whichever is finished first, i would add RootPanel.get(id).add(widget) into onSuccess. I can not add same widgets two times in both onSuccess(). So i am out of mind how to resolve this. Any logic pls. On Mon, Aug 1, 2011 at 9:08 PM, Jens jens.nehlme...@gmail.com wrote: Its not possible to stop execution as RPC requests are async. The only thing you can do is to put your code that has to wait into the onSuccess method of your RPC call. -- J. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/hgRZHjACARUJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.