|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vaadin.navigator.Navigator
public class Navigator
Navigator utility that allows switching of views in a part of an application.
The view switching can be based e.g. on URI fragments containing the view
name and parameters to the view. There are two types of parameters for views:
an optional parameter string that is included in the fragment (may be
bookmarkable).
Views can be explicitly registered or dynamically generated and listening to
view changes is possible.
Note that Navigator
is not a component itself but comes with
Navigator.SimpleViewDisplay
which is a component that displays the selected
view as its contents.
Nested Class Summary | |
---|---|
static class |
Navigator.ClassBasedViewProvider
View provider which maps a single view name to a class to instantiate for the view. |
static class |
Navigator.ComponentContainerViewDisplay
View display that replaces the contents of a ComponentContainer
with the active View . |
static class |
Navigator.EmptyView
Empty view component. |
static class |
Navigator.SimpleViewDisplay
View display that is a component itself and replaces its contents with the view. |
static class |
Navigator.StaticViewProvider
View provider which supports mapping a single view name to a single pre-initialized view instance. |
static class |
Navigator.UriFragmentManager
Fragment manager using URI fragments of a Page to track views and enable listening to view changes. |
Constructor Summary | |
---|---|
Navigator(ComponentContainer container)
Create a navigator that is tracking the active view using URI fragments of the current Page and replacing the contents of a
ComponentContainer with the active view. |
|
Navigator(FragmentManager fragmentManager,
ViewDisplay display)
Create a navigator. |
|
Navigator(Page page,
ViewDisplay display)
Create a navigator that is tracking the active view using URI fragments. |
Method Summary | |
---|---|
void |
addListener(ViewChangeListener listener)
Listen to changes of the active view. |
void |
addView(String viewName,
Class<? extends View> viewClass)
Register for a view name a view class. |
void |
addView(String viewName,
View view)
Register a static, pre-initialized view instance for a view name. |
protected void |
fireViewChange(ViewChangeListener.ViewChangeEvent event)
Fire an event when the current view has changed. |
ViewDisplay |
getDisplay()
Returns the ViewDisplay used by the navigator. |
protected FragmentManager |
getFragmentManager()
Return the fragment manager that is used to get, listen to and manipulate the URI fragment or other source of navigation information. |
protected boolean |
isViewChangeAllowed(ViewChangeListener.ViewChangeEvent event)
Check whether view change is allowed. |
void |
navigateTo(String viewAndParameters)
Navigate to a view and initialize the view with given parameters. |
protected void |
navigateTo(View view,
String viewName,
String fragmentParameters)
Internal method activating a view, setting its parameters and calling listeners. |
void |
registerProvider(ViewProvider provider)
Register a view provider (factory). |
void |
removeListener(ViewChangeListener listener)
Remove a view change listener. |
void |
removeView(String viewName)
Remove view from navigator. |
void |
unregisterProvider(ViewProvider provider)
Unregister a view provider (factory). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Navigator(ComponentContainer container)
Page
and replacing the contents of a
ComponentContainer
with the active view.
In case the container is not on the current page, use another
Navigator(Page, ViewDisplay)
with an explicitly created
Navigator.ComponentContainerViewDisplay
.
All components of the container are removed each time before adding the
active Navigator.EmptyView
. Views must implement Component
when using
this constructor.
After all Navigator.EmptyView
s and ViewProvider
s have been registered,
the application should trigger navigation to the current fragment using
e.g.
navigator.navigateTo(Page.getCurrent().getFragment());
container
- ComponentContainer whose contents should be replaced with the
active view on view changepublic Navigator(Page page, ViewDisplay display)
After all Navigator.EmptyView
s and ViewProvider
s have been registered,
the application should trigger navigation to the current fragment using
e.g.
navigator.navigateTo(Page.getCurrent().getFragment());
page
- whose URI fragments are useddisplay
- where to display the viewspublic Navigator(FragmentManager fragmentManager, ViewDisplay display)
Navigator(Page, ViewDisplay)
which uses a URI fragment based
fragment manager.
Note that navigation to the initial view must be performed explicitly by
the application after creating a Navigator using this constructor.
fragmentManager
- fragment manager keeping track of the active view and enabling
bookmarking and direct navigationdisplay
- where to display the viewsMethod Detail |
---|
public void navigateTo(String viewAndParameters)
ViewChangeListener
s are called upon successful view
change.
viewAndParameters
- view name and parametersprotected void navigateTo(View view, String viewName, String fragmentParameters)
view
- view to activateviewName
- (optional) name of the view or null not to set the fragmentfragmentParameters
- parameters passed in the fragment for the viewprotected boolean isViewChangeAllowed(ViewChangeListener.ViewChangeEvent event)
event
- view change event (not null, view change not yet performed)
protected FragmentManager getFragmentManager()
public ViewDisplay getDisplay()
Navigator.SimpleViewDisplay
(which is a Component
) is
used by default.
protected void fireViewChange(ViewChangeListener.ViewChangeEvent event)
event
- view change event (not null)public void addView(String viewName, View view)
viewName
- String that identifies a view (not null nor empty string)view
- Navigator.EmptyView
instance (not null)public void addView(String viewName, Class<? extends View> viewClass)
viewName
- String that identifies a view (not null nor empty string)viewClass
- Navigator.EmptyView
class to instantiate when a view is requested
(not null)public void removeView(String viewName)
addView(String, View)
or addView(String, Class)
.
viewName
- name of the view to removepublic void registerProvider(ViewProvider provider)
provider
- provider to registerpublic void unregisterProvider(ViewProvider provider)
provider
- provider to unregisterpublic void addListener(ViewChangeListener listener)
listener
- Listener to invoke after view changes.public void removeListener(ViewChangeListener listener)
listener
- Listener to remove.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |