GWT:对复杂的地方进行标记化

发布于 2024-11-15 05:54:56 字数 429 浏览 3 评论 0原文

GWTMVP 模式,我希望有一个地方可以代表更复杂的状态(与只有“名称”的规范示例相反) 。我的第一个倾向是使用一个共享传输对象,我将其序列化为令牌。但是,Gson(我正在使用的序列化库)似乎并不GWT 兼容。

我开始自己手动序列化和反序列化,但这似乎是一个相当常见的用例。所以我的问题是:标记一个地方的复杂状态的“普通”方法是什么?

Using GWT with the MVP pattern, I'd like to have a place that represents a somewhat more complex state (as opposed to the canonical example that has only a "name"). My first inclination was to use a shared transfer object that I would serialize for the token. However, Gson (the serialization library I'm using), does not appear to be GWT compatible.

I started down the path of manually serializing and deserializing myself, but this seemed like a use case that must be fairly common. So my question is: what is the "ordinary" means of tokenizing a the complex state of a place?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

棒棒糖 2024-11-22 05:54:56

历史标记是 URL 的一部分,并显示在浏览器地址栏中。为了完成这项工作,您首先需要对它们进行序列化,然后对它们进行 URL 编码。 URL 的长度也有实际限制:什么是不同浏览器中 URL 的最大长度?

您打算为此 URL 添加书签吗?如果没有,您应该将对象存储在某个 ID 下的映射中,并将该 ID 包含在令牌中。

如果您确实需要沿着您的路线走下去,那么通过 叠加类型

History tokens are part of URL and show up in the browser address bar. To make this work you'd first need to serialize them, then URL encode them. Also there are practical limits to how long the URL can be: What is the maximum length of a URL in different browsers?

Do you plan to bookmark this URL? If not, you should just store the object in a map under some ID and include this id in a token.

If you do need to go down your route then generating JSON in GWT is most easily done via Overlay Types.

慕烟庭风 2024-11-22 05:54:56

我们也遇到了这个问题。

我们所做的是在该位置使用对象ID并将对象存储在服务器上,这使得URL更加友好,缺点是需要额外调用服务器来恢复对象。

该解决方案的另一个优点是您可以保持对对象的控制,可以随时更新它。

We had this problem too.

What we did was to use the object ID in the place and store the object at the server, this makes the URL more friendly, the drawback is the extra call to the server to recover the object.

Another advantage of this solution is that you keep control over the object, you can update it at any moment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文