when I login i just want to go to
localhost:8080
I never want to go to a
localhost:8080/someView
or see that ?continue…
how can I disable this?
when I login i just want to go to
localhost:8080
I never want to go to a
localhost:8080/someView
or see that ?continue…
how can I disable this?
Hi,
Unfortunately, there is no setting that can disable rerouting to the last view. However, you can override the LoginViewSupport bean and provide a custom implementation for the showInitialView() method that strictly opens the main view by calling navigateToMainView() without any additional checks.
Thank you for your response.
Is there an example on how to do this? It is super annoying because I want to restrict the user to make a selection after login and then load the rest of the screens.
Hi,
not sure but maybe this can help here.
To set a default view, I modify MainView.java like this:
//default view
@Override
public void beforeEnter(BeforeEnterEvent event) {
if (event.getLocation().getPath().isEmpty()) {
event.forwardTo(StartView.class);
}
}
StartView.class is the name of the default view.
Kind regards,
Mladen
Thanks for your response.
It somewhat works. But I need to show a list of options make a selection… save that in a session variable and then allow the other screens. I hide the Menu from the left hand drawer since this grid is in the initial layout.
I ended up doing something like this… its a little clunky because the wrong page loads then reloads to root… There has to be a way to have a setting to not route someone to previously visited page especially if they depend from a session variable to load data that is selected on my root page.
@Subscribe
public void onInit(final InitEvent event) {
if (!isInMainPage()) {
UI.getCurrent().getPage().setLocation("/");
}
}
public boolean isInMainPage() {
String currentURL = VaadinService.getCurrentRequest().getHeader("referer");
return !currentURL.contains("?") && currentURL.replace("://", "").split("/").length <= 1;
}