You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Vaadin 24 with a RouterLayout and trying to refresh the router content without refreshing all the other components of the RouterLayout.
Using UI.getCurrent().getPage().reload(); does a full page refresh which is not the UX I want. If I use UI.getCurrent().navigate(...), then it simply reuses the previous router component. This means I need to implement logic that checks if it is a refresh or not and update accordingly.
I want to avoid this overhead and simply have a new instance of the router component so that the content is recreated and acts as a refresh. I tried manipulating the router through UI.getCurrent().getInternals().getRouter(), but could not find a solution.
Is this in any way possible? I can only find issues talking about preserve on refresh.
In the end, I would like something like UI.getCurrent().getPage().refreshRoute(); or UI.getCurrent().getRoute().refresh(); that would make sure a new instance of the route component is created and RouterLayout.showRouterLayoutContent(HasElement content) is called again.
There should also not be any new entry in the browser session history (History). So that navigating back goes to a previous page and not again to the same page.
The text was updated successfully, but these errors were encountered:
I found a workaround. It is a hack as I have to use the getInternals() method which is not a stable API and should not really be used as I understood.
I basically clear the routerTargetChain in UIInternals using a fake location. Then I do the actual navigation using the NavigationTrigger.PROGRAMMATIC trigger to avoid a browser history entry.
Location location = ...; // the location corresponding to the route I want to refresh
UI.getCurrent().getInternals().showRouteTarget(new Location("random"), new Div(), null);
UI.getCurrent().getInternals().getRouter().navigate(UI.getCurrent(), location, NavigationTrigger.PROGRAMMATIC);
This results in the behaviour that I need. Did I miss something that can do the same, but in a clean way? Or is this a feature that could be added?
@mshabarov I just came across a use case for this as well. I know it's pretty late for 24.4.. but this looks like a neat and easy addition; some Users and even your Copilot would love to have 😉
@knoobie good point, let's see how development goes, I'm okay to include it into 24.4 even though it's in beta already. Copilot experience was the main point, indeed.
I am using Vaadin 24 with a
RouterLayout
and trying to refresh the router content without refreshing all the other components of the RouterLayout.Using
UI.getCurrent().getPage().reload();
does a full page refresh which is not the UX I want. If I useUI.getCurrent().navigate(...)
, then it simply reuses the previous router component. This means I need to implement logic that checks if it is a refresh or not and update accordingly.I want to avoid this overhead and simply have a new instance of the router component so that the content is recreated and acts as a refresh. I tried manipulating the router through
UI.getCurrent().getInternals().getRouter()
, but could not find a solution.Is this in any way possible? I can only find issues talking about preserve on refresh.
In the end, I would like something like
UI.getCurrent().getPage().refreshRoute();
orUI.getCurrent().getRoute().refresh();
that would make sure a new instance of the route component is created andRouterLayout.showRouterLayoutContent(HasElement content)
is called again.There should also not be any new entry in the browser session history (History). So that navigating back goes to a previous page and not again to the same page.
The text was updated successfully, but these errors were encountered: