Skip to content

Instantly share code, notes, and snippets.

@ms-tg
Created January 12, 2012 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ms-tg/1603027 to your computer and use it in GitHub Desktop.
Save ms-tg/1603027 to your computer and use it in GitHub Desktop.
./TIMWeb/src/main/java/gwt/example01firstlight/client/Example01FirstLight.java
package gwt.example01firstlight.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import static gwt.example01firstlight.client.Example01FirstLightService.App;
public class Example01FirstLight implements EntryPoint {
@Override public void onModuleLoad() {
setupWidgetsForFirstLight();
}
private void setupWidgetsForFirstLight() {
com.google.gwt.user.client.ui.Button button = new com.google.gwt.user.client.ui.Button("Say hello to server...");
final TextBox textbox = new TextBox();
final Label output = new Label("");
button.addClickHandler(new com.google.gwt.event.dom.client.ClickHandler() {
@Override
public void onClick(com.google.gwt.event.dom.client.ClickEvent event) {
App.getInstance().getMessage(textbox.getValue(), new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
output.setText("Error: failed to connect to server\n" + caught);
}
@Override
public void onSuccess(String result) {
output.setText(result);
}
});
}
});
RootPanel.get("gwt_experiment").add(new Label("Enter name: "));
RootPanel.get("gwt_experiment").add(textbox);
RootPanel.get("gwt_experiment").add(button);
RootPanel.get("gwt_experiment").add(output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment