Redirect from route to another route

I have a simple application with a LoginView class (route “”) and a MainView class (route “main”). This classes implements BeforeEnterObserver where session validation is checked. If session is valid i need to move on “main” from “” and the opposite if session is outdated. I’ve trayed reroute and works but the url is not rewrited…
I see navigate() method from UI and works, the url is rewrited, but this only is executed if associated to component (button click event for exemple)

Is possible to have a small example for this? I did not find anything about this on Google for vaadin 10…
Can someone help me? Thank you

If event.rerouteTo(OtherView.class); (or event.rerouteTo("other-route");) in beforeEnter doesn’t update the URL, I’d consider that a bug. Is that the case?


I’ve this LoginView class

public class LoginView extends VerticalLayout implements BeforeEnterObserver {

    private EntityManager entityManager;
    boolean session = true;

    public LoginView() {
        TextField username = new TextField("Username");
        PasswordField password = new PasswordField("Password");
        Button loginButton = new Button("Login");
                buttonClickEvent -> doLogin(username.getValue(), password.getValue()));
        loginButton.getElement().setAttribute("theme", "primary");
        HorizontalLayout buttonsLayout = new HorizontalLayout(loginButton);
        VerticalLayout divLayout = new VerticalLayout(username, password, buttonsLayout);
        divLayout.setAlignSelf(Alignment.END, buttonsLayout);
        Div loginDiv = new Div(divLayout);

    public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
        if (session == true) {

And this MainView class:

public class MainView extends VerticalLayout {

    public MainView() {
        Label label = new Label("main");


After started application if i browse i see “main” label (the MainView class is loaded) but the URL is not It’s not changed! My framework version is 10.0.0.beta10.

Is this a bug or i’ve error in my code?

I made a ticket about it:


Olli Tietäväinen:
I made a ticket about it:


Thank you so much Olli Tietäväinen!