Example usage for com.vaadin.server VaadinSession setCurrent

List of usage examples for com.vaadin.server VaadinSession setCurrent

Introduction

In this page you can find the example usage for com.vaadin.server VaadinSession setCurrent.

Prototype

public static void setCurrent(VaadinSession session) 

Source Link

Document

Sets the thread local for the current session.

Usage

From source file:org.lucidj.navigatormanager.ProxyViewProvider.java

License:Apache License

private void clear_view(Object departing_view) {
    String current_state = navigator.getState();
    View current_view = navigator.getCurrentView();

    Iterator<Map.Entry<String, View>> it_view = view_name_to_view.entrySet().iterator();

    while (it_view.hasNext()) {
        Map.Entry<String, View> entry = it_view.next();

        if (entry.getValue() == departing_view) {
            it_view.remove();/*w  w  w  .ja v a  2 s.  c  om*/

            if (entry.getKey().equals(current_state) || entry.getValue().equals(current_view)) {
                // We are running from system land, no sessions at all, so
                // we need to set Vaadin session from navigator UI session
                VaadinSession current = VaadinSession.getCurrent();
                VaadinSession.setCurrent(navigator.getUI().getSession());

                // We always have a dedicated home view
                navigator.navigateTo(NavigatorManager.HOME);

                // Back to system land defaults
                VaadinSession.setCurrent(current);
            }
        }
    }
}