PDA

View Full Version : how to add a widget in a AsyncCallback Method to a extral widget



TOMMYZHANG
11 Sep 2009, 11:06 PM
public class Gwt_test2 implements EntryPoint {
public void onModuleLoad() {

final ContentPanel aC =new ContentPanel();
GreetingServiceAsync.Util.getInstance().getTransLastDay(new AsyncCallback<dataUtil>(){
@Override
public void onFailure(Throwable caught) {

com.google.gwt.user.client.Window.alert("dfdf");
}
@Override
public void onSuccess(dataUtil result) {

aC.add(new Button("dsfsdf"));
}});

RootPanel.get().add(aC);

}
}

this is my code example.i want to add a button in the onseccess() method to cp(a contentpanel which difined in onModuleLoad()method ),but it didnot work .the widget button had not appeared in contentpanel cp.
so how can i do if i want be add a widget to cp?
thanks!


tommy

suresh.sivanantham
12 Sep 2009, 4:16 AM
public class Gwt_test2 implements EntryPoint {
public void onModuleLoad() {

final ContentPanel aC =new ContentPanel();
GreetingServiceAsync.Util.getInstance().getTransLastDay(new AsyncCallback<dataUtil>(){
@Override
public void onFailure(Throwable caught) {

com.google.gwt.user.client.Window.alert("dfdf");
}
@Override
public void onSuccess(dataUtil result) {

aC.add(new Button("dsfsdf"));
aC.layout();
}});

RootPanel.get().add(aC);

}
}

call layout() after u add any components to contentPanel.... or setLayoutOnChange(true) for content panel.

aechannaveen
10 Jul 2011, 9:35 AM
yeah it solved mine too..thanks a lot