简体   繁体   中英

reloading page with parameter in url fragment adds extra slash character in vaadin

I am calling

getUI().getNavigator().navigateTo("myview/param=myparam");

and the Navigator opens the View registered as "myview" where the parameters can be obtained from the ViewChangeEvent by calling

event.getParameters()

which returns "param=myparam". My browser displays the url

myapp/#!myview/param=myparam

However, if I reload the page (eg using F5)

getUI().getNavigator().navigateTo("!myview/param=myparam");

(note the extra exclamation mark) will be called and the url changes to

myapp/#!myview//param=myparam

(note the double slash which is not supposed to be a comment), which obviously is a problem and actually every page reload adds another slash. Am I doing something wrong here or how else can this be resolved ? I am using CDIViewProvider which might be of interest.

Note: It looks like someone had a similar problem here Vaadin 7 url navigation hashbang but this does not answer my question.

I did not realize that when pressing F5 the UI is reloaded. There was a call like

String uriFragment = getPage().getUriFragment();
getUI().getNavigator().navigateTo(uriFragment);

in the initialization code of my UI class. Apparently the exclamation mark is included in the return of getUriFragment(), ie it returns "!myview/param=myparam". I fixed this by simply stripping the exclamation mark at this point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM