Package ej.navigation

Class Page


  • public abstract class Page
    extends Object
    The unit of navigation.

    An application creates a screen by extending this class and implementing getContent(). A page is a lightweight factory for its visual content, not the content itself: the navigator asks the page to build its widget each time the page is about to be shown, so a fresh widget is produced on every navigation to the page.

    A page is never constructed by the Navigator: the application's PageFactory builds it from the page's int key. Per-navigation data is supplied through the page's own constructor (constructor injection performed by the factory); the framework owns no parameter slot, and the public navigation API accepts keys, never page instances. The data itself may come from the navigation that triggered the build: Navigator.navigateTo(int, Object) and Navigator.replaceWith(int, Object) carry an argument to PageFactory.create(int, Object), which the factory injects. A page navigates through Navigator.getInstance().

    Since:
    0.2.0
    • Constructor Detail

      • Page

        public Page()
    • Method Detail

      • getContent

        protected abstract Widget getContent()
        Creates the visual content of this page.

        Called by the Navigator when the page is about to be shown. A fresh widget is produced on each navigation to the page.

        Returns:
        the visual content of this page.
      • onEntered

        protected void onEntered()
        Notifies this page that it has become the active page.

        Invoked immediately after the navigation operation, before the transition animation starts. A navigation requested from this callback is deferred and performed once the navigation in progress is finished. This default implementation does nothing.

      • onExited

        protected void onExited()
        Notifies this page that it has ceased to be the active page.

        Invoked with the same timing as onEntered(). This default implementation does nothing.