GWT。设置网址,无需提交 [英] GWT. Set url without submit

查看:107
本文介绍了GWT。设置网址,无需提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在不提交的情况下更改网址(设置参数)吗?
我发现此方法
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/Window .Location.html#替换%28java.lang.String%29
,但它提交页面。所有的GWT状态都将丢失。

Can i change url(set parameter) without submit? I found this method http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/Window.Location.html#replace%28java.lang.String%29 but it submit page. All GWT state will be lost.

推荐答案

你为什么要这样做?一般来说,GWT应用程序不会更改页面 - 因此它们通常是 SPA> (单页应用程序)

Why are you trying to do this? Generally speaking, GWT apps don't change pages - thus they are normally SPAs (single page applications)

当您从一台服务器,你将失去该页面上的状态。您可以更改URL的哈希部分,因为它不会返回到服务器,如下所示:

When you load a new page from a server, you will lose the state on that page. You can change the hash part of the URL as that won't return to the server, like this:

String newURL = Window.Location.createUrlBuilder().setHash("newhash").buildString();
Window.Location.replace(newURL);

但是,如果您打算这样做,我建议您查看GWT的MVP框架,它支持使用哈希令牌管理位置。

However, if you're going to do this, I would recommend taking a look at GWT's MVP framework, which has built in support for managing locations using hash tokens.

http://code.google.com/webtoolkit/doc/latest/DevGuideMvpActivitiesAndPlaces.html

这篇关于GWT。设置网址,无需提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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