Does BeforeEnterEvent execute before target view instantiation?
0 reputation · 05 Apr 2024, 20:43 UTC
Vaadin applications utilize a route-based navigation system where views annotated with @Route are accessible by default. To prevent accidental public access, developers typically integrate Spring Security or use the BeforeEnterEvent to intercept navigation and verify authentication before the target view is rendered.
There is a concern regarding the precise sequence of the navigation lifecycle. Specifically, it is unclear if the framework instantiates the target view component before the BeforeEnterEvent logic is fully processed. If the view is instantiated prior to the access check, it could lead to unnecessary resource allocation or the execution of constructor logic for unauthorized users.
Which phase of the navigation lifecycle triggers the instantiation of the view class relative to the BeforeEnterEvent? Does this behavior vary when using @PermitAll versus manual programmatic checks?