GWT页面显示处理:RPC调用

public class DemoClient implements EntryPoint {

public void onModuleLoad() {
final SampleServiceAsync sampleService = (SampleServiceAsync) 
GWT.create(SampleService.class);
        ServiceDefTarget target = (ServiceDefTarget)sampleService;
         String staticResponseURL = GWT.getModuleBaseURL();
        staticResponseURL += "/getStringService";
         target.setServiceEntryPoint(staticResponseURL);
        
         final Label label = new Label();
         final Button button = new Button("Get String");
        
         button.addClickListener(new ClickListener() {
             public void onClick(Widget sender) {
                sampleService.getString(new AsyncCallback() {
                     public void onSuccess(Object result) {
                         label.setText((String) result);
                     }
                     public void onFailure(Throwable caught) {
                         label.setText(caught.getMessage());
                    }
                 });
             }
         });

         RootPanel.get("1").add(button);
         RootPanel.get("2").add(label);
     }
}

你可能感兴趣的:(gwt)