Package io.jmix.flowui.view.navigation
Class RouteSupport
java.lang.Object
io.jmix.flowui.view.navigation.RouteSupport
Utility bean that facilitates url modifications and generations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected jakarta.servlet.ServletContextprotected UrlParamSerializer -
Constructor Summary
ConstructorsConstructorDescriptionRouteSupport(UrlParamSerializer urlParamSerializer, jakarta.servlet.ServletContext servletContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddQueryParameter(com.vaadin.flow.component.UI ui, String name, Object value) Updates the current url by adding the value of the given query parameter.voidaddQueryParameter(com.vaadin.flow.component.UI ui, String name, List<Object> values) Updates the current url by adding the value of the given query parameter.com.vaadin.flow.router.QueryParametersaddQueryParameter(com.vaadin.flow.router.QueryParameters queryParameters, String name, Object value) Creates a newQueryParametersobject by adding to it the value of the given query parameter.com.vaadin.flow.router.QueryParametersaddQueryParameter(com.vaadin.flow.router.QueryParameters queryParameters, String name, List<Object> values) Creates a newQueryParametersobject by adding to it the value of the given query parameter.convertValues(List<Object> values) com.vaadin.flow.router.RouteParameterscreateRouteParameters(String param, Object value) CreatesRouteParametersobject which stores a single route parameter with given name and value.voidfetchCurrentLocation(com.vaadin.flow.component.UI ui, Consumer<com.vaadin.flow.router.Location> callback) Retrieves the current url from the browser and converts it to theLocationobject.com.vaadin.flow.router.LocationgetActiveViewLocation(com.vaadin.flow.component.UI ui) Gets theLocationof the currently shown view.protected com.vaadin.flow.router.RouteConfigurationcom.vaadin.flow.router.QueryParametersmergeQueryParameters(com.vaadin.flow.router.QueryParameters... parameters) Creates a newQueryParametersobject by merging passed query parameters into one.voidreplaceUrl(com.vaadin.flow.component.UI ui, Class<? extends com.vaadin.flow.component.Component> navigationTarget, com.vaadin.flow.router.RouteParameters routeParameters) Invokeshistory.replaceStatein the browser with a new location generated by combining the url which navigates to given navigation target using given parameters and current query parameters.resolveLocationString(URL url) Creates a string containing a relative URL excluding query parameters.com.vaadin.flow.router.QueryParametersresolveQueryParameters(String queryString) CreatesQueryParametersobject from a query string.com.vaadin.flow.router.QueryParametersCreatesQueryParametersobject from the query part of the givenURLobject.voidsetQueryParameter(com.vaadin.flow.component.UI ui, String name, Object value) Updates the current url by setting the value of the given query parameter.voidsetQueryParameter(com.vaadin.flow.component.UI ui, String name, List<Object> values) Updates the current url by setting the value of the given query parameter.com.vaadin.flow.router.QueryParameterssetQueryParameter(com.vaadin.flow.router.QueryParameters queryParameters, String name, Object value) Creates a newQueryParametersobject by setting to it the value of the given query parameter.com.vaadin.flow.router.QueryParameterssetQueryParameter(com.vaadin.flow.router.QueryParameters queryParameters, String name, List<Object> values) Creates a newQueryParametersobject by setting to it the value of the given query parameter.voidsetQueryParameters(com.vaadin.flow.component.UI ui, com.vaadin.flow.router.QueryParameters queryParameters) Overrides the current url query parameters with the values represented byQueryParametersobject.protected voidupdateQueryParameters(com.vaadin.flow.component.UI ui, String name, List<Object> values, org.apache.commons.lang3.function.TriFunction<com.vaadin.flow.router.QueryParameters, String, List<Object>, com.vaadin.flow.router.QueryParameters> updater)
-
Field Details
-
urlParamSerializer
-
servletContext
protected jakarta.servlet.ServletContext servletContext
-
-
Constructor Details
-
Method Details
-
fetchCurrentLocation
public void fetchCurrentLocation(com.vaadin.flow.component.UI ui, Consumer<com.vaadin.flow.router.Location> callback) Retrieves the current url from the browser and converts it to theLocationobject. The URL is fetched from the browser in another request asynchronously and theLocationobject passed to the callback.- Parameters:
ui- UI instance for which to fetch current locationcallback- to be notified when the location is resolved
-
getActiveViewLocation
public com.vaadin.flow.router.Location getActiveViewLocation(com.vaadin.flow.component.UI ui) Gets theLocationof the currently shown view. The location is relative the servlet mapping used for serving the related UI.- Parameters:
ui- UI instance for which to get active view location- Returns:
- the view
Location, notnull
-
addQueryParameter
Updates the current url by adding the value of the given query parameter. If a query parameter with the same name already exists, the new value is added excluding duplicates, otherwise the query parameter is added.- Parameters:
ui- UI instance for which to update urlname- the query parameter namevalue- the query parameter value
-
addQueryParameter
Updates the current url by adding the value of the given query parameter. If a query parameter with the same name already exists, the new value is added excluding duplicates, otherwise the query parameter is added.- Parameters:
ui- UI instance for which to update urlname- the query parameter namevalues- the query parameter values
-
setQueryParameter
Updates the current url by setting the value of the given query parameter. If a query parameter with the same name already exists, its value is overridden, otherwise the query parameter is added.- Parameters:
ui- UI instance for which to update urlname- the query parameter namevalue- the query parameter value
-
setQueryParameter
Updates the current url by setting the value of the given query parameter. If a query parameter with the same name already exists, its value is overridden, otherwise the query parameter is added.- Parameters:
ui- UI instance for which to update urlname- the query parameter namevalues- the query parameter values
-
updateQueryParameters
-
setQueryParameters
public void setQueryParameters(com.vaadin.flow.component.UI ui, com.vaadin.flow.router.QueryParameters queryParameters) Overrides the current url query parameters with the values represented byQueryParametersobject.- Parameters:
ui- UI instance for which to update urlqueryParameters- an object which holds query parameters information
-
mergeQueryParameters
public com.vaadin.flow.router.QueryParameters mergeQueryParameters(com.vaadin.flow.router.QueryParameters... parameters) Creates a newQueryParametersobject by merging passed query parameters into one. If several objects have the same query parameter information, the latest have precedence.- Parameters:
parameters- query parameters to merge- Returns:
- a new
QueryParametersobject which holds query parameters information.
-
addQueryParameter
public com.vaadin.flow.router.QueryParameters addQueryParameter(com.vaadin.flow.router.QueryParameters queryParameters, String name, Object value) Creates a newQueryParametersobject by adding to it the value of the given query parameter. If a query parameter with the same name already exists, the new value is added excluding duplicates, otherwise the query parameter is added.- Parameters:
queryParameters- theQueryParametersobject to updatename- the query parameter namevalue- the query parameter value- Returns:
- a new
QueryParametersobject which holds query parameters information.
-
addQueryParameter
public com.vaadin.flow.router.QueryParameters addQueryParameter(com.vaadin.flow.router.QueryParameters queryParameters, String name, List<Object> values) Creates a newQueryParametersobject by adding to it the value of the given query parameter. If a query parameter with the same name already exists, the new value is added excluding duplicates, otherwise the query parameter is added.- Parameters:
queryParameters- theQueryParametersobject to updatename- the query parameter namevalues- the query parameter values- Returns:
- a new
QueryParametersobject which holds query parameters information.
-
setQueryParameter
public com.vaadin.flow.router.QueryParameters setQueryParameter(com.vaadin.flow.router.QueryParameters queryParameters, String name, Object value) Creates a newQueryParametersobject by setting to it the value of the given query parameter. If a query parameter with the same name already exists, its value is overridden, otherwise the query parameter is added.- Parameters:
queryParameters- theQueryParametersobject to updatename- the query parameter namevalue- the query parameter value- Returns:
- a new
QueryParametersobject which holds query parameters information.
-
setQueryParameter
public com.vaadin.flow.router.QueryParameters setQueryParameter(com.vaadin.flow.router.QueryParameters queryParameters, String name, List<Object> values) Creates a newQueryParametersobject by setting to it the value of the given query parameter. If a query parameter with the same name already exists, its value is overridden, otherwise the query parameter is added.- Parameters:
queryParameters- theQueryParametersobject to updatename- the query parameter namevalues- the query parameter values- Returns:
- a new
QueryParametersobject which holds query parameters information.
-
resolveLocationString
Creates a string containing a relative URL excluding query parameters.- Parameters:
url- aURLobject to obtain location- Returns:
- a string representing a relative URL excluding query parameters.
-
resolveQueryParameters
CreatesQueryParametersobject from the query part of the givenURLobject.- Parameters:
url- aURLobject to obtain query parameters- Returns:
- a
QueryParametersobject which holds query parameters information.
-
resolveQueryParameters
CreatesQueryParametersobject from a query string.- Parameters:
queryString- a string to parse- Returns:
- a
QueryParametersobject which holds query parameters information.
-
createRouteParameters
CreatesRouteParametersobject which stores a single route parameter with given name and value.- Parameters:
param- the route parameter namevalue- the route parameter value- Returns:
- an object which stores the route parameters
-
replaceUrl
public void replaceUrl(com.vaadin.flow.component.UI ui, Class<? extends com.vaadin.flow.component.Component> navigationTarget, com.vaadin.flow.router.RouteParameters routeParameters) Invokeshistory.replaceStatein the browser with a new location generated by combining the url which navigates to given navigation target using given parameters and current query parameters.- Parameters:
ui- UI instance for which to update urlnavigationTarget- navigation targetrouteParameters- route parameters- Throws:
com.vaadin.flow.router.NotFoundException- in case the navigationTarget is not registered with a url template matching the given parameters.
-
convertValues
-
getRouteConfiguration
protected com.vaadin.flow.router.RouteConfiguration getRouteConfiguration()
-