Interface PageFactory
-
public interface PageFactoryBuilds thePagefor a page key.An application implements this interface once and supplies the single instance to
Navigator.initialize(ej.mwt.Desktop, PageFactory). The navigator callscreate(int, Object)only when a navigation pushes a new history entry or replaces the active one — that is, fromNavigator.navigateTo(int)andNavigator.replaceWith(int). Back navigations (Navigator.navigateBack()andNavigator.navigateBackTo(int)) never call it: they re-show thePageinstance the navigator cached in its history, so a page's fields survive a round trip through back navigation.The factory is where per-navigation data is injected. Along with the key, it receives the argument the navigation carried — the one given to
Navigator.navigateTo(int, Object)orNavigator.replaceWith(int, Object), andnullfor the overloads that carry none — and passes it to the page's own constructor. The navigator keeps no reference to that argument and imposes no parameter slot onPage, so the page decides what it stores and in which type.The navigator is not passed to
create(int, Object): a factory, or a page it builds, reaches it withNavigator.getInstance(), so a page can trigger navigation without a separately wired back-reference.- Since:
- 0.2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Pagecreate(int key, Object argument)Creates the page identified by the given key, injecting the given per-navigation argument.
-
-
-
Method Detail
-
create
Page create(int key, @Nullable Object argument) throws IllegalArgumentException
Creates the page identified by the given key, injecting the given per-navigation argument.Called by the navigator when a navigation pushes a new history entry (
Navigator.navigateTo(int)) or replaces the active one (Navigator.replaceWith(int)); it is not called on back navigation, which re-shows the cached page. A fresh page is expected on each call; the returned page must not benull.The argument is the one the navigation carried, and is
nullwhen it carried none. A factory that resolves a key expecting an argument is responsible for checking what it received: the navigator neither inspects the argument nor matches it against the key.- Parameters:
key- the non-negative key of the page to create.argument- the argument the navigation carried, ornullif it carried none.- Returns:
- the page for the given key.
- Throws:
IllegalArgumentException- if the given key does not identify any page.
-
-