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调用
最新推荐文章于 2024-07-27 11:32:49 发布
本文展示了一个使用 GWT (Google Web Toolkit) 实现的示例客户端应用,该应用通过调用 SampleService 异步获取字符串,并显示结果。具体包括初始化服务入口、创建按钮和标签以供用户交互。
324

被折叠的 条评论
为什么被折叠?



