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页面显示处理:RPC调用
最新推荐文章于 2021-05-31 09:31:48 发布