Navigator won't navigate to any page if it's from the session

I’m trying to do access control the old fashion. If a user is in the session, go to a specif page. On page reload it should take to the designated page as well. I’m attempting to do so the following way but failed. What am I doing wrong? any help will be greatly appreciated.

package org.example.test;


import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.*;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author mhossain_c
 */
public class NavigatorTest extends UI
{

    Navigator navigator;

    public enum Views
    {

        TEST, ANOTHER
    };

    @Override
    protected void init(VaadinRequest request)
    {
        Panel mainPanel = new Panel();
        mainPanel.setSizeFull();
        setContent(mainPanel);

        // Trying to load the second page if a session already exists
        // For actual app, this would if there are any user stored 
        if (VaadinSession.getCurrent().getAttribute(Navigator.class) != null)
        {
            VaadinSession.getCurrent().getAttribute(Navigator.class).
                    navigateTo(Views.ANOTHER.name());
        }
        else
        {
            navigator = new Navigator(this, mainPanel);
            navigator.addView(Views.TEST.name(), new Test());
            navigator.addView(Views.ANOTHER.name(), new Another());
            navigator.navigateTo(Views.TEST.name());
            VaadinSession.getCurrent().setAttribute(Navigator.class, navigator);
        }
    }

}

class Test extends Panel implements View
{

    @Override
    public void enter(ViewChangeEvent event)
    {
        //Do nothing
    }

    public Test()
    {
        Label label = new Label("This should be displayed first time app load");
        setContent(label);
    }

}


class Another extends Panel implements View
{

    @Override
    public void enter(ViewChangeEvent event)
    {
        //Do nothing
    }

    public Another()
    {
        Label label = new Label("If navigator already exists in the session "
                + ", upon reload this should be displayed");
        setContent(label);
    }

}

In Vaadin 6, the application and the whole state was preserved between page reloads. In Vaadin 7 you can choose whether it should be preserved or not, where ‘not’ is the default. I am not sure if this extends also to the VaadinSession. If it does, it would mean that the attribute list would be cleaned between every refresh, and the app would always go to the ‘else’-part of the clause. This choice between the preservation can be altered by giving the UI the annotation @PreserveOnRefresh, but that would mean that you would only get the old UI back and it wouldn’t run the init-method again, which means that the if-else wouldn’t be re-evauluated.

Thanks for reply.

It doesn’t always go to the else part. In the debugger, it’ll execute navigateTo() but nothing would happen. Just an empty page.

Unfortunately with @PreserveOnRefresh mechanism, if the user somehow enters a erroneous state, refreshing it keeps bringing them back to the erroneous state. For example, messing with the URL (http://localhost:8080/WebApplication1/#!TEST - > http://localhost:8080/WebApplication1/)

So is this a bug or an expected outcome? How do I recover from this state without ?restartApplication