Interface ViewContextStrategy
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ViewContextStrategies.EveryNavigation,ViewContextStrategies.ViewName,ViewContextStrategies.ViewNameAndParameters
Decision strategy on whether target navigation state belongs to active view
context. When the target navigation state does not belong to the active view
context, the current context will be released and a new one is created.
By default the views are using the Dependent scope, which can be used
but is not recommended. Any View with a ViewContextStrategy
should use one of the scopes provided in the Vaadin CDI integration.
Separate annotations annotated by ViewContextStrategyQualifier have
to exist for each of the implementations.
Example of a custom implementation:
A separate annotation.
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
@ViewContextStrategyQualifier
public @interface MyStrategyAnnotation {
}
An implementation class.
@NormalUIScoped
@MyStrategyAnnotation
public class MyStrategy implements ViewContextStrategy {
public boolean contains(String viewName, String parameters) {
...
}
}
Use annotation on the view.
@CDIView("myView")
@MyStrategyAnnotation
public MyView implements View {
...
}
-
Method Summary
Modifier and TypeMethodDescriptionbooleaninCurrentContext(String viewName, String parameters) Returns whether the active context contains target navigation state.
-
Method Details
-
inCurrentContext
Returns whether the active context contains target navigation state. This method should compare the current navigation state and the one given through the parameters and decide if the current context should be held open or released.- Parameters:
viewName- target navigation view nameparameters- target navigation parameters- Returns:
trueto hold context open;falseto release it
-