Vaadin 8 how to handle Views, Navigator and Menu?

636 views Asked by At

In Vaadin 8 I am currently developing a Web App and I am struggling with the menu / view management / navigator...
Since I am completely new to servlets and Vaadin, I am not quite sure if my approach will work / if i understood this correctly.
I thought to have understood Vaadin like this:
- The app runs on my server.
- For every user that accesses it, a new instance of my UI is created

Now I want to have a nice design to manage the navigator (which maps strings to views) and my menu (which needs a String to display and the key string to pass to the navigator).

My current idea is to use an Enum like this:

public Enum ViewManager {

  HOME("home", "Home", new HomeView()),
  ANOTHER_VIEW("another", "Another View", new AnotherView());

  private final String stateName, menuName;
  private final View view;

  MenuEntry(String stateName, String menuName, View view) {
    this.stateName = stateName;
    this.menuName = menuName;
    this.view = view;
}

Then I could develop the Menu to create entries by iterating over ViewManager.values().
I could add views to the UI navigator using navigator.addView(String, view) (I dislike navigator.addView(String, Class<View>) since it will create a new view instance every time one navigates.

Long story short: Will this work or will I have interference between multiple users when they change view attributes. (especially dangerous when users try to access sensible data like email, password,... for example in a loginView)

0

There are 0 answers