Interface ViewChangeListener
-
- All Superinterfaces:
Serializable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ViewChangeListener extends Serializable
Interface for listening to View changes before and after they occur.Implementations of this interface can also block navigation between views before it is performed (using
beforeViewChange(ViewChangeEvent)).The interface contains two methods
beforeViewChange(ViewChangeEvent)andafterViewChange(ViewChangeEvent). The latter one has default empty implementation.- Since:
- 7.0
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classViewChangeListener.ViewChangeEventEvent received by the listener for attempted and executed view changes.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidafterViewChange(ViewChangeListener.ViewChangeEvent event)Invoked after the view is changed.booleanbeforeViewChange(ViewChangeListener.ViewChangeEvent event)Invoked before the view is changed.
-
-
-
Method Detail
-
beforeViewChange
boolean beforeViewChange(ViewChangeListener.ViewChangeEvent event)
Invoked before the view is changed.This method may e.g. open a "save" dialog or question about the change, which may re-initiate the navigation operation after user action.
If this listener does not want to block the view change (e.g. does not know the view in question), it should return true. If any listener returns false, the view change is not allowed and
afterViewChange()methods are not called.- Parameters:
event- view change event- Returns:
- true if the view change should be allowed or this listener does not care about the view change, false to block the change
-
afterViewChange
default void afterViewChange(ViewChangeListener.ViewChangeEvent event)
Invoked after the view is changed. If abeforeViewChangemethod blocked the view change, this method is not called. Be careful of unbounded recursion if you decide to change the view again in the listener.By default it does nothing. Override it in your listener if you need this functionality.
- Parameters:
event- view change event
-
-