diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-09-27 11:40:17 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-09-27 11:40:17 +0300 |
commit | 367c7751a6ff9234fd47bc5a48e6ef9a4117a7a2 (patch) | |
tree | 5b3849bafb37b49c3dcc8616e064f60bd081dff0 /uitest | |
parent | 69776b1d08d40bcdd89b9cc5b050e8db793ec06b (diff) | |
download | vaadin-framework-367c7751a6ff9234fd47bc5a48e6ef9a4117a7a2.tar.gz vaadin-framework-367c7751a6ff9234fd47bc5a48e6ef9a4117a7a2.zip |
Add option to use PushState instead of URI fragments in Navigator (#10042)
* Navigator now by default uses pushState and normal URLs
* added documentation for pushState and updated Navigator documentation
* improving docs etc, adding one TODO to be solved before merging
* pushState/replaceState no work better with changing titles
* Making uri fragment navigator work when not using specially mapped UI
* Revert to older default, add annotation for selecting
* Fix tests, add null checks
* Reorder if-clause, fix tests
* Revert unnecessary test change
* Use correct variable in UI, fix test clean up
* Updates to JavaDocs, fix some methods and tests
* Add comments, fix test ui, TODO for fallbacks
* Navigation documentation, JavaDocs, removed TODOs
* Documentation fixes
* Improve JavaDocs
* Fix link name in documentation
* Improve throws declaration in getLocation
* Change documentation about the PushState based navigation
* Add since tags
* Add since tags for UI
Diffstat (limited to 'uitest')
5 files changed, 33 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/main/java/com/vaadin/launcher/ApplicationRunnerServlet.java index 6835b5fb0b..97689033d5 100644 --- a/uitest/src/main/java/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/main/java/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -52,6 +52,7 @@ import com.vaadin.server.SystemMessages; import com.vaadin.server.SystemMessagesInfo; import com.vaadin.server.SystemMessagesProvider; import com.vaadin.server.UIClassSelectionEvent; +import com.vaadin.server.UICreateEvent; import com.vaadin.server.UIProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinService; @@ -59,6 +60,7 @@ import com.vaadin.server.VaadinServlet; import com.vaadin.server.VaadinServletRequest; import com.vaadin.server.VaadinServletService; import com.vaadin.server.VaadinSession; +import com.vaadin.shared.ApplicationConstants; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.UI; import com.vaadin.util.CurrentInstance; @@ -267,6 +269,13 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { return (Class<? extends UI>) classToRun; } + + @Override + public UI createInstance(UICreateEvent event) { + event.getRequest().setAttribute(ApplicationConstants.UI_ROOT_PATH, + "/" + event.getUIClass().getName()); + return super.createInstance(event); + } } // TODO Don't need to use a data object now that there's only one field diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/PushStateAndReplaceState.java b/uitest/src/main/java/com/vaadin/tests/components/ui/PushStateAndReplaceState.java index 22788f326c..962bcb95ca 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ui/PushStateAndReplaceState.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ui/PushStateAndReplaceState.java @@ -2,6 +2,7 @@ package com.vaadin.tests.components.ui; import java.net.URI; +import com.vaadin.annotations.Title; import com.vaadin.server.Page; import com.vaadin.server.Page.PopStateEvent; import com.vaadin.server.Page.PopStateListener; @@ -13,6 +14,7 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; +@Title("Original title") public class PushStateAndReplaceState extends AbstractReindeerTestUI { private final Label locationLabel = new Label(); @@ -48,6 +50,7 @@ public class PushStateAndReplaceState extends AbstractReindeerTestUI { Button button = new Button(caption, new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { + getPage().setTitle(caption); if (replace.getValue()) { getPage().replaceState(newUri); } else { diff --git a/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorViewBlocksBackButtonAction.java b/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorViewBlocksBackButtonAction.java index 60be2f6e74..9a62729bd3 100644 --- a/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorViewBlocksBackButtonAction.java +++ b/uitest/src/main/java/com/vaadin/tests/navigator/NavigatorViewBlocksBackButtonAction.java @@ -1,6 +1,7 @@ package com.vaadin.tests.navigator; import com.vaadin.navigator.Navigator; +import com.vaadin.navigator.PushStateNavigation; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; @@ -13,6 +14,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; +@PushStateNavigation public class NavigatorViewBlocksBackButtonAction extends AbstractReindeerTestUI { diff --git a/uitest/src/main/webapp/WEB-INF/web.xml b/uitest/src/main/webapp/WEB-INF/web.xml index b1ec909d21..1771a0bd98 100644 --- a/uitest/src/main/webapp/WEB-INF/web.xml +++ b/uitest/src/main/webapp/WEB-INF/web.xml @@ -151,6 +151,20 @@ <async-supported>true</async-supported> </servlet> + <servlet> + <servlet-name>Navigator test</servlet-name> + <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> + <init-param> + <param-name>UI</param-name> + <param-value>com.vaadin.tests.navigator.NavigatorViewBlocksBackButtonAction</param-value> + </init-param> + <async-supported>true</async-supported> + </servlet> + + <servlet-mapping> + <servlet-name>Navigator test</servlet-name> + <url-pattern>/navigator-test/*</url-pattern> + </servlet-mapping> <servlet-mapping> <servlet-name>Embed App 1</servlet-name> <url-pattern>/embed1/*</url-pattern> diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupPositionEmbeddedInDivTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupPositionEmbeddedInDivTest.java index 2845283c7a..682712dcbb 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupPositionEmbeddedInDivTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupPositionEmbeddedInDivTest.java @@ -49,4 +49,9 @@ public class ComboBoxPopupPositionEmbeddedInDivTest extends MultiBrowserTest { Assert.assertTrue("Popup should be left aligned with the combobox", popupLocation.getX() == comboboxLocation.getX()); } + + @Override + protected Class<?> getUIClass() { + return ComboBoxEmbeddedInDiv.class; + } } |