(file) Return to test.java CVS log (file) (dir) Up to [Development] / GWTAntTasks / src / com / pjaol / client

 1 pjaol 1.1 package com.pjaol.client;
 2           
 3           import com.google.gwt.core.client.EntryPoint;
 4           import com.google.gwt.core.client.GWT;
 5           import com.google.gwt.user.client.rpc.AsyncCallback;
 6           import com.google.gwt.user.client.rpc.ServiceDefTarget;
 7           import com.google.gwt.user.client.ui.Button;
 8           import com.google.gwt.user.client.ui.ClickListener;
 9           import com.google.gwt.user.client.ui.Label;
10           import com.google.gwt.user.client.ui.RootPanel;
11           import com.google.gwt.user.client.ui.Widget;
12           
13           /**
14            * Entry point classes define <code>onModuleLoad()</code>.
15            */
16           public class test implements EntryPoint {
17           
18             /**
19              * This is the entry point method.
20              */
21             public void onModuleLoad() {
22 pjaol 1.1     final Button button = new Button("Click me");
23               final Label label = new Label();
24               
25               button.addClickListener(new ClickListener() {
26                 public void onClick(Widget sender) {
27                   if (label.getText().equals(""))
28                     //label.setText("Hello World!");
29                   	getMyId("fish food", label);
30                   else
31                     label.setText("");
32                 }
33               });
34           
35               // Assume that the host HTML has elements defined whose
36               // IDs are "slot1", "slot2".  In a real app, you probably would not want
37               // to hard-code IDs.  Instead, you could, for example, search for all 
38               // elements with a particular CSS class and replace them with widgets.
39               //
40               RootPanel.get("slot1").add(button);
41               RootPanel.get("slot2").add(label);
42             }
43 pjaol 1.1   
44             
45             public void getMyId (String s , final Label label) {
46           	  
47           	TestGWTAsync service = (TestGWTAsync) GWT.create(TestGWT.class);
48           	ServiceDefTarget endPoint = (ServiceDefTarget)service;
49           	String moduleRelativeURL = GWT.getModuleBaseURL() + "/testGWT";
50           	endPoint.setServiceEntryPoint(moduleRelativeURL);
51           
52           
53           	AsyncCallback callback = new AsyncCallback() {
54           	    public void onSuccess(Object result) {
55           	      label.setText((String) result);
56           	    }
57           
58           	    public void onFailure(Throwable caught) {
59           	      label.setText("nope :-(");
60           	    }
61           	  };
62           	  service.getReturnId("fish food", callback);
63             }
64 pjaol 1.1 }

cvsadmin
Powered by
ViewCVS 0.9.2