summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2012-06-25 09:57:22 +0300
committerHenri Sara <hesara@vaadin.com>2012-06-25 09:57:22 +0300
commit58ca6dff762e14512d4e4a9fec92a27345988b52 (patch)
tree7ac8f555d2cad5f7d18be2f4dd60eee982e67df9 /src/com
parentbd85f96658b15159af3f7e8159047a6057290502 (diff)
downloadvaadin-framework-58ca6dff762e14512d4e4a9fec92a27345988b52.tar.gz
vaadin-framework-58ca6dff762e14512d4e4a9fec92a27345988b52.zip
Fixes for Navigator: empty view name, no extra event, javadoc (#8859)
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/navigator/Navigator.java34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/com/vaadin/navigator/Navigator.java b/src/com/vaadin/navigator/Navigator.java
index 387f1d4eae..3ff727b504 100644
--- a/src/com/vaadin/navigator/Navigator.java
+++ b/src/com/vaadin/navigator/Navigator.java
@@ -1,9 +1,9 @@
+package com.vaadin.navigator;
+
/*
-@VaadinApache2LicenseForJavaFiles@
+ @VaadinApache2LicenseForJavaFiles@
*/
-package com.vaadin.navigator;
-
import java.io.Serializable;
import java.util.Iterator;
import java.util.LinkedList;
@@ -16,7 +16,6 @@ import com.vaadin.terminal.Page.FragmentChangedListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Root;
/**
* Navigator utility that allows switching of views in a part of an application.
@@ -60,7 +59,7 @@ public class Navigator implements Serializable {
}
/**
- * Fragment manager using URI fragments of a Root to track views and enable
+ * Fragment manager using URI fragments of a Page to track views and enable
* listening to view changes.
*
* This class is mostly for internal use by Navigator, and is only public
@@ -73,10 +72,10 @@ public class Navigator implements Serializable {
/**
* Create a new URIFragmentManager and attach it to listen to URI
- * fragment changes of a {@link Root}.
+ * fragment changes of a {@link Page}.
*
- * @param root
- * root whose URI fragment to get and modify
+ * @param page
+ * page whose URI fragment to get and modify
* @param navigator
* {@link Navigator} to notify of fragment changes (using
* {@link Navigator#navigateTo(String)}
@@ -93,8 +92,7 @@ public class Navigator implements Serializable {
}
public void setFragment(String fragment) {
- // TODO ", false" ???
- page.setFragment(fragment);
+ page.setFragment(fragment, false);
}
public void fragmentChanged(FragmentChangedEvent event) {
@@ -272,7 +270,7 @@ public class Navigator implements Serializable {
/**
* Create a navigator that is tracking the active view using URI fragments.
*
- * @param root
+ * @param page
* whose URI fragments are used
* @param display
* where to display the views
@@ -280,6 +278,7 @@ public class Navigator implements Serializable {
public Navigator(Page page, ViewDisplay display) {
this.display = display;
fragmentManager = new UriFragmentManager(page, this);
+ navigateTo(page.getFragment());
}
/**
@@ -287,21 +286,25 @@ public class Navigator implements Serializable {
* By default, a {@link SimpleViewDisplay} is used and can be obtained using
* {@link #getDisplay()}.
*
- * @param root
+ * @param page
* whose URI fragments are used
*/
public Navigator(Page page) {
display = new SimpleViewDisplay();
fragmentManager = new UriFragmentManager(page, this);
+ navigateTo(page.getFragment());
}
/**
* Create a navigator.
*
* When a custom fragment manager is not needed, use the constructor
- * {@link #Navigator(Root, ViewDisplay)} which uses a URI fragment based
+ * {@link #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.
+ *
* @param fragmentManager
* fragment manager keeping track of the active view and enabling
* bookmarking and direct navigation
@@ -335,12 +338,13 @@ public class Navigator implements Serializable {
* view name and parameters
*/
public void navigateTo(String viewAndParameters) {
- String longestViewName = "";
+ String longestViewName = null;
View viewWithLongestName = null;
for (ViewProvider provider : providers) {
String viewName = provider.getViewName(viewAndParameters);
if (null != viewName
- && viewName.length() > longestViewName.length()) {
+ && (longestViewName == null || viewName.length() > longestViewName
+ .length())) {
View view = provider.getView(viewName);
if (null != view) {
longestViewName = viewName;