Created
January 12, 2012 20:50
-
-
Save ms-tg/1603027 to your computer and use it in GitHub Desktop.
./TIMWeb/src/main/java/gwt/example01firstlight/client/Example01FirstLight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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