GWT 2.1地点/活动技巧故障:确认导航之前的URL更改 [英] GWT 2.1 Place/Activity technique glitch: URL changes before navigation is confirmed

查看:159
本文介绍了GWT 2.1地点/活动技巧故障:确认导航之前的URL更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读此Google指南并使用< a href =http://code.google.com/p/google-web-toolkit/downloads/detail?name=Tutorial-hellomvp-2.1.zip =nofollow>此示例代码由google提供 a>,但有一个小故障:使用前后按钮会在确认对话框返回之前更改URL。这意味着,如果用户决定不导航,URL不再代表当前位置。



任何人都有解决方案或解决方法?理想情况下,只有在给出确认之后URL才会更改,但即使只是在拒绝之后立即将网址切换回来也会更好。

解决方案 div>

没有解决方法。您的应用程序以某种方式检测到URL已更改,从而触发地点更改(因此在导航确认之前)。



无法知道为什么 URL改变了;它是一个回?一个第四?使用历史记录菜单返回一次回几步?书签?手动编辑URL?因此,您无法在所有情况下都使用History.next()来取消URL更改(还要注意它会触发另一个地方更改)。试图用History.back / next / go以外的其他内容来修改网址会清除转发历史记录,而这些历史记录您可能都不想看到。



仅供参考,我两年前在我自己的地方经理中实现了这一行为,并在RayHay将它添加到GWT 2.1时与Ray Ryan讨论了这一点,并且我们同意没有更好的行为而不是让URL不再与地点。仅供参考,当我在2年前研究这个事情时,然后在今年早些时候,GMail也有同样的行为(创建草稿消息并导航,而草稿未保存更改)。

I'm reading this google guide and using this sample code provided by google, but there's a glitch: using the back/forth buttons makes the URL change before the confirmation dialog has returned. This means that if the user decides not to navigate away, the URL no longer represents the current Place.

Anyone have a solution or workaround? Ideally, the URL would not change until the confirmation is given, but even just switching the URL back in a hurry after a denial would be better.

解决方案

There's no workaround. Your app somehow detects that the URL has changed, which triggers the place change (thus before navigation is confirmed).

And there's no way to know why the URL changed; was it a "back"? a "forth"? a "back" using the history menu to go several steps back at a time? a bookmark? manual editing of the URL? So there's no way you could do a History.next() to "cancel" the URL change in all cases (also note that it would trigger another place change). And trying to modify the URL with anything else than History.back/next/go would erase the forward history, which you probably don't want either.

FYI, I implemented that behavior 2 years ago in my own "place manager", and talked about it with Ray Ryan when he added the PlaceHistoryHandler to GWT 2.1, and we agreed that there was no better behavior than letting the URL no longer being in sync with the place. FYI, when I studied the thing 2 years ago, and then earlier this year, GMail had the same behavior (create a draft message and navigate while the draft has unsaved changes).

这篇关于GWT 2.1地点/活动技巧故障:确认导航之前的URL更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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