1 package org.aupa.client;
2
3 import com.google.gwt.core.client.EntryPoint;
4 import com.google.gwt.user.client.ui.Button;
5 import com.google.gwt.user.client.ui.ClickListener;
6 import com.google.gwt.user.client.ui.Label;
7 import com.google.gwt.user.client.ui.RootPanel;
8 import com.google.gwt.user.client.ui.Widget;
9
10 import com.google.gwt.core.client.GWT;
11 import com.google.gwt.user.client.rpc.AsyncCallback;
12 import com.google.gwt.user.client.rpc.ServiceDefTarget;
13
14
15
16
17
18
19 public class App implements EntryPoint {
20
21
22
23
24 public void onModuleLoad() {
25 final Button button = new Button("Click me");
26 final Label label = new Label();
27
28
29 final ServiceAsync remoteService = (ServiceAsync) GWT.create(Service.class);
30
31 ServiceDefTarget endpoint = (ServiceDefTarget) remoteService;
32 String moduleRelativeURL = GWT.getModuleBaseURL() + "Service";
33 endpoint.setServiceEntryPoint(moduleRelativeURL);
34
35 final AsyncCallback callback = new AsyncCallback() {
36 public void onSuccess(Object result) {
37 label.setText("Answer from Server: '" + result.toString() + "'");
38 }
39 public void onFailure(Throwable caught) {
40 label.setText("Server error: " + caught.getMessage());
41 }
42 };
43
44 button.addClickListener(new ClickListener() {
45 public void onClick(Widget sender) {
46 remoteService.myMethode("Hi Server", callback);
47 }
48 });
49
50
51
52
53
54
55 RootPanel.get("slot1").add(button);
56 RootPanel.get("slot2").add(label);
57 }
58 }