GWT. Set url without submit

后端 未结 3 565
太阳男子
太阳男子 2021-01-18 06:35

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#

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-18 07:12

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

    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);
    

    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

提交回复
热议问题