diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-11-22 14:47:24 +0200 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2012-11-22 14:47:24 +0200 |
commit | 4e5c3181b5465bfb37a5f616656b239b3e98f798 (patch) | |
tree | 01c6c49519e01ceda94a9a77ad97289dc579f7ce | |
parent | 2ddae8d39d813ba261f09f71547cd0b3160f6b37 (diff) | |
download | vaadin-framework-4e5c3181b5465bfb37a5f616656b239b3e98f798.tar.gz vaadin-framework-4e5c3181b5465bfb37a5f616656b239b3e98f798.zip |
Kickstart navigation automatically after UI.init(), remove Navigator.navigate() (#9549, 10239)
Change-Id: I3537eb8f289e75234d6a292636019429967280c3
-rw-r--r-- | server/src/com/vaadin/navigator/Navigator.java | 64 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/UI.java | 6 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/navigator/NavigatorTest.java | 2 |
3 files changed, 33 insertions, 39 deletions
diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java index acfaf45516..72128adddf 100644 --- a/server/src/com/vaadin/navigator/Navigator.java +++ b/server/src/com/vaadin/navigator/Navigator.java @@ -360,20 +360,18 @@ public class Navigator implements Serializable { /** * Creates a navigator that is tracking the active view using URI fragments - * of the current {@link Page} and replacing the contents of a - * {@link ComponentContainer} with the active view. - * <p> - * In case the container is not on the current page, use another - * {@link Navigator#Navigator(Page, ViewDisplay)} with an explicitly created - * {@link ComponentContainerViewDisplay}. + * of the {@link Page} containing the given UI and replacing the contents of + * a {@link ComponentContainer} with the active view. * <p> * All components of the container are removed each time before adding the * active {@link View}. Views must implement {@link Component} when using * this constructor. * <p> - * After all {@link View}s and {@link ViewProvider}s have been registered, - * the application should trigger navigation to the current fragment using - * {@link #navigate()}. + * Navigation is automatically initiated after {@code UI.init()} if a + * navigator was created. If at a later point changes are made to the + * navigator, {@code navigator.navigateTo(navigator.getState())} may need to + * be explicitly called to ensure the current view matches the navigation + * state. * * @param ui * The UI to which this Navigator is attached. @@ -387,18 +385,16 @@ public class Navigator implements Serializable { /** * Creates a navigator that is tracking the active view using URI fragments - * of the current {@link Page} and replacing the contents of a - * {@link SingleComponentContainer} with the active view. - * <p> - * In case the container is not on the current page, use another - * {@link Navigator#Navigator(Page, ViewDisplay)} with an explicitly created - * {@link SingleComponentContainerViewDisplay}. + * of the {@link Page} containing the given UI and replacing the contents of + * a {@link SingleComponentContainer} with the active view. * <p> * Views must implement {@link Component} when using this constructor. * <p> - * After all {@link View}s and {@link ViewProvider}s have been registered, - * the application should trigger navigation to the current fragment using - * {@link #navigate()}. + * Navigation is automatically initiated after {@code UI.init()} if a + * navigator was created. If at a later point changes are made to the + * navigator, {@code navigator.navigateTo(navigator.getState())} may need to + * be explicitly called to ensure the current view matches the navigation + * state. * * @param ui * The UI to which this Navigator is attached. @@ -412,11 +408,13 @@ public class Navigator implements Serializable { /** * Creates a navigator that is tracking the active view using URI fragments - * of the Page containing the given UI. + * of the {@link Page} containing the given UI. * <p> - * After all {@link View}s and {@link ViewProvider}s have been registered, - * the application should trigger navigation to the current fragment using - * {@link #navigate()}. + * Navigation is automatically initiated after {@code UI.init()} if a + * navigator was created. If at a later point changes are made to the + * navigator, {@code navigator.navigateTo(navigator.getState())} may need to + * be explicitly called to ensure the current view matches the navigation + * state. * * @param ui * The UI to which this Navigator is attached. @@ -430,13 +428,14 @@ public class Navigator implements Serializable { /** * Creates a navigator. * <p> - * When a custom navigation state manager is not needed, use the constructor - * {@link #Navigator(Page, ViewDisplay)} which uses a URI fragment based - * state manager. + * When a custom navigation state manager is not needed, use one of the + * other constructors which use a URI fragment based state manager. * <p> - * After all {@link View}s and {@link ViewProvider}s have been registered, - * the application should trigger navigation to the current fragment using - * {@link #navigate()}. + * Navigation is automatically initiated after {@code UI.init()} if a + * navigator was created. If at a later point changes are made to the + * navigator, {@code navigator.navigateTo(navigator.getState())} may need to + * be explicitly called to ensure the current view matches the navigation + * state. * * @param ui * The UI to which this Navigator is attached. @@ -457,15 +456,6 @@ public class Navigator implements Serializable { } /** - * Navigates to the current navigation state. This method should be called - * when all required {@link View}s, {@link ViewProvider}s, and - * {@link ViewChangeListener}s have been added to the navigator. - */ - public void navigate() { - navigateTo(getStateManager().getState()); - } - - /** * Navigates to a view and initialize the view with given parameters. * <p> * The view string consists of a view name optionally followed by a slash diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index a5e8f5e508..89a36e198e 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -552,6 +552,12 @@ public abstract class UI extends AbstractSingleComponentContainer implements // Call the init overridden by the application developer init(request); + + Navigator navigator = getNavigator(); + if (navigator != null) { + // Kickstart navigation if a navigator was attached in init() + navigator.navigateTo(navigator.getState()); + } } /** diff --git a/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java index 08832e5e82..f35c8b876d 100644 --- a/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java +++ b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java @@ -129,8 +129,6 @@ public class NavigatorTest extends UI { navi.setErrorView(new ErrorView()); - navi.navigate(); - layout.addComponent(new NaviButton("list")); layout.addComponent(new NaviButton("edit")); layout.addComponent(new NaviButton("forbidden")); |