I need to reload navigation target

Hello,
I am using vaadin 24.3.12 and I have a view, where the user changes some permissions and after that I need to reload the application or navigate to the mainLayout and reload (like to enter the application again) but I am not getting it. I am navigating to the destination view but it is not reloading.

@Route(value = ‘UserConfigurationView’, layout = MainLayout.class)
@PageTitle(‘UserConfiguration’)
@Slf4j
@UIScope
@SpringComponent
public class UserConfigurationView extends VerticalLayout
@Path(‘’)
@SpringComponent
@RouteAlias(‘home’)
@UIScope
@PageTitle(‘MyApplication’)
public class MainLayout extends AppLayout

I have also tried this…

SourceView:

UI.getCurrent().navigate(MainLayout.class,new RouteParameters(‘reload’, ‘true’));

TargetView (Parameter is always null):

public class MainLayout extends AppLayout implements BeforeEnterObserver.

 @Override
    public void beforeEnter(BeforeEnterEvent event) {
        String reload = event.getRouteParameters().get(‘reload’).
                orElse(null);
        if (reload != null) {
        	...
        }
    }

Could you help me pls?
Thanks in advance.
Regards.

RouteParameter should be used in combination with route parameters or route templates (e.g. @Route("mypath/:reload").

You can make your class a parameter/template view or use query parameters (event.getLocation().getQueryParameters().getParameters("reload").

Another solution to do force page reload could be to use UI.getCurrent().getPage().setLocation("/home");

1 Like

The easiest way to reload the page and rebuild the component annotated with @UIScope is to call UI.getCurrent().getPage().reload(); or getUI().ifPresent( ui -> ui..getPage().reload())

2 Likes

Thank you @marcoc_753 !

Thank you @Jean-Christophe.1 !!