This is a Vaadin add-on project that you can find in the Vaadin Directory.
Official releases, examples and implementation instructions can be found over there.
This addon provides a builder-style way of programming navigation in Vaadin.
It enriches the existing functionality. No widgetset compiling required.
- Builder-style navigation implementations;
- Open (external) url's in current or new tab;
- Navigate to url fragments (like '/app');
- Navigate through browser history (back/next);
- Make use of pre-configured navigations;
- Attach your own listeners to be executed upon navigation;
- Navigate right away, or prepare your navigation and perform it later (or again).
Immediate navigation to external url in new tab with listener:
NavigationUtils.navigate()
.to("www.google.com")
.inNewTab()
.withListener(event1 -> LOGGER.trace("Navigating to external url in a new tab."))
.go();
Immediate navigation to fragment with listener:
NavigationUtils.navigate()
.toLocation("/register")
.withListener(e -> LOGGER.trace("Navigating to " + e.getUrl()))
.go();
Simple pre-configured navigations:
NavigationUtils.createReloadNavigation().withListener(l -> System.out.println("Page reloaded!")).go(); // Adding a listener to the pre-configured navigation.
NavigationUtils.createBackNavigation().go(); // Go back one page in the browser history
NavigationUtils.createNextNavigation().go(); // Go one page forward in the browser history
Preparing multiple navigations, adding a listener to them and performing them (note that you probably wouldn't perform multiple navigations at the same time):
List<NavigationBuilder> navigations = new ArrayList<>();
NavigationBuilder reload = NavigationUtils.navigate().reload();
NavigationBuilder openGoogleInNewTab = NavigationUtils.navigate()
.to("http://www.google.com")
.inNewTab();
NavigationListener navigationListener = navigationEvent -> {
LOGGER.info("Some custom navigation of type: {} was executed.", navigationEvent.getNavigationType());
};
navigations.add(reload);
navigations.add(openGoogleInNewTab);
navigations.forEach(builder -> {
builder.withListener(navigationListener);
builder.go();
});