Why vaadin duplicates View's methods invocation?

Hi All,

Please find the post below


My Question is also same, I too face the same problem, can anybody let me know the resolutions with Examples ?

Thanks in advance


The enter() method in the View interface is called
every time
the view is opened. So if you add components to the view in the enter() method, then you will get duplicates every time you open the view. Either initialize the components in constructor of the view or use a flag to check if the view has already been initialized. Another alternative is to register the views to the navigator using class objects instead of view instances. In this case, a new view instance is created every time you navigate to the view. Here’s how you do it

So instead of calling navigator.addView("myview", new MyView()); you should call navigator.addView("myview", MyView.class);