Skip to content

Instantly share code, notes, and snippets.

@develar
Created January 17, 2015 14:20
Show Gist options
  • Save develar/fa092f4c9ef12325ecba to your computer and use it in GitHub Desktop.
Save develar/fa092f4c9ef12325ecba to your computer and use it in GitHub Desktop.
package com.mySampleApplication.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>
*/
public class MySampleApplication implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Button button = new Button("Click me");
internalMethod();
final Label label = new Label();
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (label.getText().equals("")) {
MySampleApplicationService.App.getInstance().getMessage("Hello, World!", new MyAsyncCallback(label));
} else {
label.setText("");
}
internalMethod();
}
});
// Assume that the host HTML has elements defined whose
// IDs are "slot1", "slot2". In a real app, you probably would not want
// to hard-code IDs. Instead, you could, for example, search for all
// elements with a particular CSS class and replace them with widgets.
//
RootPanel.get("slot1").add(button);
RootPanel.get("slot2").add(label);
}
private void internalMethod(){
boolean test = false;
String var = "TEST";
double x = 1.0;
}
private static class MyAsyncCallback implements AsyncCallback<String> {
private Label label;
public MyAsyncCallback(Label label) {
this.label = label;
}
public void onSuccess(String result) {
label.getElement().setInnerHTML(result);
}
public void onFailure(Throwable throwable) {
label.setText("Failed to receive answer from server!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment