Based on the button click in Vaadin application, I'd like to change the browser URL value. I'd like to add some GET parameters to the URL. Please advise how to implement this with Vaadin 23.
Asked
Active
Viewed 220 times
0
-
1Do you mean you want to implement something as described here https://vaadin.com/docs/latest/routing/navigation/#passing-data-using-route-parameters? – Tarek Oraby Aug 07 '22 at 17:50
-
Thank you! Yes, something like that, but as far as I understand - I may use this solution when I plan to navigate to the different view? In my case I'd like to stay on the same page, just update the current url (when the user configures search filter) in order to allow user to bookmark it or share with others. How to implement this without navigation to other pages? – alexanoid Aug 07 '22 at 18:04
-
1Have you tried https://vaadin.com/docs/latest/routing/updating-url-parameters – cfrick Aug 07 '22 at 18:36
-
1If you navigate to some URL that is matched by the current view, then the view instance will be reused but methods to react to navigation changes, e.g. `setParameter`, will be called again. – Leif Åstrand Aug 07 '22 at 18:43
-
If your problem is solved please provide the solution as the answer. This may be helpful for others. Thank – Simon Martinelli Aug 08 '22 at 06:40
1 Answers
1
I use the following code to update the browser url:
String baseUrl = RouteConfiguration.forSessionScope().getUrl(getClass());
String urlWithParameters = baseUrl + //add parameters here
getUI().get().getPage().getHistory().replaceState(null, urlWithParameters);

alexanoid
- 24,051
- 54
- 210
- 410