Hi everyone!
I’m having some issues with the
Navigator
in my app after using the browser back button. Let me explain the situation:
Our app has a login page and some “logged in” pages, nothing fancy. The only “weird” thing is that the login page has a different layout than the “logged in” pages. Let me clarify this:
Login page:
[font=courier new]
-------------------
| Login view |
-------------------
[/font]
“Logged in” pages:
[font=courier new]
|
Menu | Content
|
[/font]
In the “logged in” pages, the “content” view is the one passed to the
Navigator
as a
ComponentContainer
. In the login page, as we don’t follow the same layout, is the
UI
what is passed to the
Navigator
as the
ComponentContainer
.
Something like this is being done on the
init()
of the
UI
:
[code]
@Override
protected void init(VaadinRequest request) {
Navigator navigator = new Navigator(this, this);
navigator.addView(“login”, LoginView.class);
navigator.navigateTo(“login”);
}
[/code]Later on, after a successful login:
[code]
// Custom View for the Layout
NavigationView navigationView = new NavigationView();
UI.getCurrent().setContent(navigationView);
Navigator navigator = new Navigator(this, navigationView.getContentView());
AppUI.getCurrentApp().setNavigator(navigator);
navigator.addView(“home”, HomeView.class);
navigator.addView(“another”, AnotherView.class);
navigator.navigateTo(“home”);
[/code]Ok, what is happening after doing this is (step by step):
- Access page, login view is loaded
- Successful login, redirect to home view
- From home view, click on link which redirects to “another” view
- Press browser back button. Get error:
“Trying to navigate to an unknown state ‘home’ and an error view provider not present”
Do you know what could be happening?
Thank you so much for your time!