Assuming my view is:
@Route(value="test")
public class TestView extends VerticalLayout implements BeforeEnterObserver {
public TestView() {
super();
// do some stuff.
new Button("Test", click -> getUI().ifPresent(ui -> ui.navigate("test")));
}
@Override
public void beforeEnter(BeforeEnterEvent event) {
// do some other stuff.
}
}
If I click on the Test button above then the constructor is not instantiated however the beforeEnter()
method is called. In my case I would much prefer to instantiate the whole view class because the beforeEnter()
method includes some logic and setup code that the view needs that if called twice can mess up the components. Specially the beforeEnter()
does some checks and depending on the details may call different component rendering paths.