来自客户端 Java 端的 GWT 查询
我试图从服务器查询一组数据。响应应该生成一个 DataTable 实例,该实例可直接用于呈现 Google Visualization Widget(饼图或其他)。
我的问题是,官方教程仅包含用于生成此类查询的 javascript 代码。
我发现,以下内容应该有效:
Query q = Query.create(url);
q.send(new Query.Callback() {
@Override
public void onResponse(QueryResponse queryResponse) {
if (!queryResponse.isError()) {
DataTable table = queryResponse.getDataTable();
}
}
});
但要使用它,您必须填写 url 字符串变量。当然,你可以只写它,但是如果你将 servlet 的映射更改为其他内容,那真的很恶心,你将不得不触及每个查询...... 有没有一种简单的方法来生成这些 url 来执行此类查询调用?
谢谢乔纳斯
Im trying to query a set of data from the server. The response should result in a DataTable instance that can be directly used to render a Google Visualization Widget (PieChart or whatever).
My Problem is, that the official tutorials only include javascript code for generating such a query..
I found out, that the following should work:
Query q = Query.create(url);
q.send(new Query.Callback() {
@Override
public void onResponse(QueryResponse queryResponse) {
if (!queryResponse.isError()) {
DataTable table = queryResponse.getDataTable();
}
}
});
But to use this you'll have to fill the url String variable. Of course you can just write it, but thats really disgusting if you change the mapping of your servlet to something else, you'll have to touch every query...
Is there a simple way to generate these urls to do such query calls?
Thx
Jonas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GWT 为客户端与服务器之间的交互提供了专门的框架 GWT-RPC。它是 100% Java,它的服务器实现基于 servlet,并且它负责低级细节,例如服务器 URL、对象序列化等。
此外,您可能会发现这个 问题相关。
GWT offers specialized framework GWT-RPC for client-server interactions. It's 100% Java, its server implementation is based on servlets, and it takes care of low-level details such as server urls, object serializations, etc.
Also, you may find this question relevant.