com.holonplatform.vaadin.flow.navigator.internal

## Class DefaultNavigator

- java.lang.Object
- - com.holonplatform.vaadin.flow.navigator.internal.DefaultNavigator

- All Implemented Interfaces:
    Navigator, Serializable

      public class DefaultNavigator
      extends Object
      implements Navigator

  Default `Navigator` implementation.
  Since:
    5.2.0
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DefaultNavigator.DefaultNavigationBuilder` Default `NavigationBuilder` implementation.

    - ### Nested classes/interfaces inherited from interface com.holonplatform.vaadin.flow.navigator.Navigator

      `Navigator.NavigationBuilder`

  - ### Field Summary

    - ### Fields inherited from interface com.holonplatform.vaadin.flow.navigator.Navigator

      `CONTEXT_KEY, DEFAULT_NAVIGATION_FAILED_MESSAGE, DEFAULT_NAVIGATION_FAILED_MESSAGE_CODE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultNavigator()` Constructor using the current UI.
    `DefaultNavigator(com.vaadin.flow.component.UI ui)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.holonplatform.core.Registration` | `addNavigationChangeListener(NavigationChangeListener navigationChangeListener)` Add a `NavigationChangeListener` to listen to navigation target/location changes.
    `<T,C extends com.vaadin.flow.component.Component & com.vaadin.flow.router.HasUrlParameter<T>> String` | `getUrl(Class<? extends C> navigationTarget, List<T> parameters)` Get the registered URL for given navigation target class, including the given `parameters` in the url.
    `String` | `getUrl(Class<? extends com.vaadin.flow.component.Component> navigationTarget)` Get the registered URL for given navigation target class.
    `void` | `navigateBack()` Navigates back.
    `void` | `navigateTo(String path, Map<String,Object> queryParameters)` Navigate to the given path, using the provided query parameters.
    `void` | `navigateToDefault()` Navigates to the default navigation target, i.e.
    `void` | `navigateToLocation(String location)` Navigate to the given location.
    `void` | `navigateToPrevious()` Navigates to the previous route, if available.
    `void` | `setPreviousLocation(com.vaadin.flow.router.Location previousLocation)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.vaadin.flow.navigator.Navigator

      `create, get, getUrl, getUrl, navigateTo, navigateTo, navigateTo, navigateTo, navigateTo, navigateTo, navigateTo, navigation, navigation`

- - ### Constructor Detail

    - #### DefaultNavigator

          public DefaultNavigator()

      Constructor using the current UI.

    - #### DefaultNavigator

          public DefaultNavigator(com.vaadin.flow.component.UI ui)

      Constructor.
      Parameters:
        `ui` - The `UI` to which the navigator is bound (not null)

  - ### Method Detail

    - #### setPreviousLocation

          public void setPreviousLocation(com.vaadin.flow.router.Location previousLocation)

      Parameters:
        `previousLocation` - the previousLocation to set

    - #### navigateToLocation

          public void navigateToLocation(String location)

      Description copied from interface: `Navigator`
      Navigate to the given location.

      The location may include a set of query path parameters, using the default `?` separator.

      Specified by:
        `navigateToLocation` in interface `Navigator`
      Parameters:
        `location` - The location to navigate to. If `null`, the default (`""`) location will be used

    - #### navigateTo

          public void navigateTo(String path,
                                 Map<String,Object> queryParameters)

      Description copied from interface: `Navigator`
      Navigate to the given path, using the provided query parameters.

      The query parameter values will be serialized to be included in the navigation location URL, using a `NavigationParameterMapper`. See the `QueryParameter` annotation to learn about the supported query parameter value types.

      Specified by:
        `navigateTo` in interface `Navigator`
      Parameters:
        `path` - The path to navigate to. If `null`, the default (`""`) path will be used
        `queryParameters` - A map of query parameters, which associates the parameter names to their values

    - #### navigateToDefault

          public void navigateToDefault()

      Description copied from interface: `Navigator`
      Navigates to the default navigation target, i.e. navigates to the empty `""` route path.
      Specified by:
        `navigateToDefault` in interface `Navigator`

    - #### navigateBack

          public void navigateBack()

      Description copied from interface: `Navigator`
      Navigates back.

      This has the same effect as if the user would press the back button in the browser.

      Specified by:
        `navigateBack` in interface `Navigator`

    - #### navigateToPrevious

          public void navigateToPrevious()

      Description copied from interface: `Navigator`
      Navigates to the previous route, if available. If a previous route is not available, navigates to the default route.

      This method can be used to navigate back in the route targets sequence handled by the UI Router or Navigator, it has not the same effect and purpose of the `Navigator.navigateBack()` method, which can be used to navigate back in the browser history.

      Specified by:
        `navigateToPrevious` in interface `Navigator`
      See Also:
        `Navigator.navigateToDefault()`

    - #### getUrl

          public String getUrl(Class<? extends com.vaadin.flow.component.Component> navigationTarget)

      Description copied from interface: `Navigator`
      Get the registered URL for given navigation target class.

      This method ignores any declared URL parameter, and always returns the navigation target base URL. To obtain the URL for a navigation target with required URL parameters, use `Navigator.getUrl(Class, List)` or `Navigator.getUrl(Class, Object)`.

      Specified by:
        `getUrl` in interface `Navigator`
      Parameters:
        `navigationTarget` - The navigation target to get URL for (not null)
      Returns:
        The URL for the given navigation target

    - #### getUrl

          public <T,C extends com.vaadin.flow.component.Component & com.vaadin.flow.router.HasUrlParameter<T>> String getUrl(Class<? extends C> navigationTarget,
                                                                                                                             List<T> parameters)

      Description copied from interface: `Navigator`
      Get the registered URL for given navigation target class, including the given `parameters` in the url.
      Specified by:
        `getUrl` in interface `Navigator`
      Type Parameters:
        `T` - URL parameters type
        `C` - Navigation target type
      Parameters:
        `navigationTarget` - The navigation target to get url for (not null)
        `parameters` - The parameters to include in the generated URL (not null)
      Returns:
        The URL for the given navigation target, including the given URL parameters

    - #### addNavigationChangeListener

          public com.holonplatform.core.Registration addNavigationChangeListener(NavigationChangeListener navigationChangeListener)

      Description copied from interface: `Navigator`
      Add a `NavigationChangeListener` to listen to navigation target/location changes.
      Specified by:
        `addNavigationChangeListener` in interface `Navigator`
      Parameters:
        `navigationChangeListener` - The listener to add (not null)
      Returns:
        The registration handler

Copyright © 2020 The Holon Platform. All rights reserved.