Pass Data to a View
The recommended way to pass data between views in a Vaadin application is through URL parameters. This approach enables deep linking, allowing users to navigate directly to a specific page or piece of content using a URL. With deep linking, users can bookmark key sections for quick access, share links with colleagues, and seamlessly navigate back using the browser’s history and back button.
However, some data structures are too complex to represent effectively as URL parameters. In these cases, you can either pass the data directly to the target view instance or store it in an intermediary object, such as the Vaadin session, and retrieve it from the target view.
You’ll find examples for all these approaches in the guides section.
Types of URL Parameters
Vaadin supports two types of URL parameters:
-
Route parameters — Part of the URL path, used to identify a specific view or content, such as a particular entity or tab.
-
Query parameters — Key-value pairs appended to the URL, ideal for storing UI state, like a grid’s sort order or a search field’s value.
|
Tip
|
Use route parameters when navigation depends on the structure of the URL, such as /customer/123 to view customer details.
|
|
Tip
|
Use query parameters for storing state that affects a view’s behavior, such as /orders?sort=date&filter=shipped.
|
Guides
The following guides explore different ways to pass data between views:
- Route Parameters
- Learn how to use route parameters in Vaadin.
- Route Templates
- Learn how to use route templates in Vaadin.
- Query Parameters
- Learn how to manage state with query parameters in Vaadin.
- Complex Data
- Learn how to pass complex data between the views of a Vaadin application.