The page cannot be refreshed immediately after navigation

I’m trying to refresh a page immediately after navigation, but the problem is that the method call refreshes the previous page.

window.location.href is equal to the URL of the previous page in all the events in where I tried to force the refresh. Any idea at what point the client location is updated?
For the same reason, always returns the previous page, even when the View is created and navigated. :cry:

Vaadin: 24.1.1
Flow: 24.1.1

I don’t understand why you want to load a page then refresh it after navigation.
When do you call page reload?

I’m trying to update MainView after substituting user. So I need to completely reload the page for the security permissions to apply, because the navigation to the MainView does not recreate it.

I tried to call page reload on afterNavigation. I also tried the previous view DetachEvent and the main view AttachEvent. Everywhere the previous page URL is returned.

Instead of navigating then refresh the page, you can call directly: ui.getPage().setLocation("yourview")

You can also dispatch a custom security event which you can listen on in your main view and update it accordingly

@faithful-emu, thank you very much for your quick response.:grinning:
I succeeded to achieve the required functionality.
I’m very grateful.

If you don’t mind, please answer one question?
Still, at what point in the life cycle of the View location of the client part is updated and synchronized with the server?

@quirky-zebra, thank you. Your method works for me too.

I don’t know the answer, I would probably go in the flow code to have an answer (or wait for someone who knows the answer)

I tried to find the answer in the flow code. And I also tried to find the answer through debugging. To no avail.

Anyway, thanks again :grinning: