GWT 可视化 API 数据表序列化 [英] GWT Visualisation API DataTable Serialization

查看:29
本文介绍了GWT 可视化 API 数据表序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循 本教程 关于如何在 GWT 中连接到数据库,但我没有创建登录程序,而是尝试从我的数据库中检索 GWT 可视化数据表,以便我可以创建带注释的时间线.我已经走了很远,但我撞到了最后一堵我无法弄清楚的墙.不像 tut,我不是从 RPC 返回一个简单的 User 类,而是一个复杂的 DataTable.问题是这个 DataTable 必须是 GWT 标准可序列化的.有什么简单的方法可以做到这一点吗?

I am trying to follow this tutorial on how to connect to a database in GWT, but instead of creating a login program, I am trying to retrieve a GWT Visulation DataTable from my DB so that I can then create a Annotated TimeLine. I have gotten very far, but I hit the final wall I can't figure out. Unlike the tut, I am not returning a simple User class from the RPC, but a complex DataTable. The problem is that this DataTable must be serializable by GWT standards. Is there any easy way for accomplish this?

出于安全原因,我使用的是 RPC,而不是查询系统.我不希望人们通过查看我的 javascript 并查看我的查询等.

I am using a RPC, instead of a Query system for security reasons. I don't want people to by able to look at my javascript and see my queries and such.

谢谢.

更新:回到问题后,我发现 DataTable 是一个 JavaScriptObject,可能永远不会在服务器端制作.所以新的问题是,手动将 DataTable 变成可序列化的东西的最佳方法是什么,然后重新制作它的客户端的最佳方法是什么.再次感谢!

UPDATE: After going back to the problem I have found that DataTable is a JavaScriptObject and was probably never meant to be made on the server side. So new question, What is the best way to manually make DataTable into something serlizable and then what is the best way to remake it client side. Thanks Again!

推荐答案

好的,所以我自己想通了(有点)所以我想我会在这里发布答案,以防其他人以后碰巧遇到同样的问题.

Ok so I figured it out myself (sorta) so I thought I would post the answer here in case someone else happens to have the same problem later.

简而言之,答案是不可能的.DataTable 是一个 JSO 对象,在 GWT 当前版本(1.6something)中它不能序列化这些类型的对象.我必须做的是将我的数据分解成一系列 ArrayLists 并将它们保存在一个临时对象中.然后可以将该对象序列化并发送到客户端.这样做的问题是您必须在客户端构造 DataTable 对象.

The answer in short that is impossible. DataTable is a JSO object, and in GWT current release (1.6something) it can not serialize those types of objects. What I had to do was break down my data into a series of ArrayLists and hold those in a temperay Object. That object can then be serialized and sent to the client side. The problem with this is that you must then construct the DataTable object on the client side.

如果其他人碰巧想出了更好的主意,我仍然有兴趣找出答案.

If anyone else happens to come up with a better idea I would still be interested on finding out.

谢谢.

-埃里克

这篇关于GWT 可视化 API 数据表序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆