com.vaadin.navigator.

Interface View

  • All Superinterfaces:

    Serializable

    All Known Implementing Classes:

    Navigator.EmptyView

    public interface View
    extends Serializable

    Interface for all views controlled by the navigator. Each view added to the navigator must implement this interface. Typically, a view is a Component, if it is not then you should override getViewComponent() to define the component to show for the view.

    Since:

    7.0

    Author:

    Vaadin Ltd

    • Method Detail

      • enter

        default void enter​(ViewChangeListener.ViewChangeEvent event)

        Called before the view is shown on screen.

        The event object contains information about parameters used when showing the view, in addition to references to the old view and the new view.

        Override this method to perform initialization of your view.

        By default does nothing.

        Parameters:

        event - an event object containing information about the parameters given by the user and references to the old view (if any)

      • beforeLeave

        default void beforeLeave​(ViewBeforeLeaveEvent event)

        Called when the user is requesting navigation away from the view.

        This method allows the view to accept or prevent navigation away from the view or optionally delay navigation away until a later stage. For navigation to take place, the ViewBeforeLeaveEvent.navigate() method must be called either directly when handling this event or later to perform delayed navigation.

        The default implementation calls ViewBeforeLeaveEvent.navigate() directly. If you override this and do nothing, the user will never be able to leave the view.

        This method is triggered before any methods in any added ViewChangeListeners. Whenever you call ViewBeforeLeaveEvent.navigate(), any ViewChangeListeners will be triggered. They will be handled normally and might also prevent navigation.

        Parameters:

        event - an event object providing information about the event and containing the ViewBeforeLeaveEvent.navigate() method needed to perform navigation

        Since:

        8.1

      • getViewComponent

        default Component getViewComponent()

        Gets the component to show when navigating to the view. By default casts this View to a Component if possible, otherwise throws an IllegalStateException.

        Returns:

        the component to show, by default the view instance itself

        Since:

        8.1