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
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
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
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
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
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
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
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