Пятница, 17 Декабря 2010 г. 17:44
+ в цитатник
Отложеная подгрузка скрипта
button3.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final MyProxy myproxy = new MyProxy();
AsyncCallback collback = new AsyncCallback() {
public void onFailure(Throwable caught) {
}
public void onSuccess(Object result) {
Timer timer = new Timer() {
@Override
public void run() {
Button btn = myproxy.getApp().getButton();
RootPanel.get().add(btn);
}
};
timer.run();
timer.scheduleRepeating(10);
}
};
myproxy.getInstance(collback);
}
});
* This source code was highlighted with Source Code Highlighter.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.yournamehere.client.util;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.ui.Button;
/**
*
* @author salnikov
*/
public interface MyApp extends RemoteService {
String getWindow();
public Button getButton();
}
* This source code was highlighted with Source Code Highlighter.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.yournamehere.client.util;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author salnikov
*/
public class MyProxy {
private MyApp app;
public void getInstance( final AsyncCallback collback ) {
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable reason) {
collback.onFailure(reason);
}
public void onSuccess() {
app = new OrgApp();
collback.onSuccess(this);
}
});
}
public MyApp getApp() {
return app;
}
public void setApp(MyApp app) {
this.app = app;
}
}
* This source code was highlighted with Source Code Highlighter.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.yournamehere.client.util;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
/**
*
* @author salnikov
*/
public class OrgApp implements MyApp {
private static int counter = 0;
public String getWindow() {
return "window from Proxy";
}
public Button getButton() {
counter++;
return new Button("num "+counter);
}
}
* This source code was highlighted with Source Code Highlighter.
Метки:
gwt
-
Запись понравилась
-
0
Процитировали
-
0
Сохранили
-