URL Parameter Mapping | Vaadin

Flexible URL parameter mapping for Vaadin Flow

URL Parameter Mapping for Vaadin Flow

While https://github.com/vaadin/flow/issues/2740 and https://github.com/vaadin/flow/issues/4213 are still in the works, the need for flexible parametrized routes still exist. This helper implementation lives on top of built in HasUrlParameter and provides support for named parameters.

Simple usage example:

import org.vaadin.flow.helper.*;

...

@Route("example")
@UrlParameterMapping(":exampleId/:orderId")
// Will match /example/12345/ORD223434, set exampleId = 12345 and
// call setOrder("ORD223434")
// Otherwise user will be rerouted to default NotFoundException view
class MyView extends Div implements HasUrlParameterMapping {
    // Note: parameter fields/setters should be public
    @UrlParameter
    public Integer exampleId;

    @UrlParameter(name = "orderId", regEx = "ORD[0-9]{6}")
    public setOrder(String order) { ... }
    ...
}

The following features are implemented:

  • Support for Integer, Long, Boolean, String and UUID properties (with automatic regular expression checks)
  • Parameter placeholders: order/:orderId
  • Optional parameters: order/:orderId[/:rowId]
  • Parameters in the middle of path: order/:orderId/edit
  • Multiple alternative mappings
  • (Optional) Automatic rerouting to view.
  • Inline regular expressions: forum/thread/:threadId/.*
  • Custom regular expressions: @UrlParameter(regEx = "overview|samples|links")
  • Dynamic regular expressions for parameters
  • RequestHandler support
  • URL formatting
  • Query parameters support

Install

Link to this version
BetaReleased 22 January 2019Apache License 2.0
Framework Support
Vaadin platform 10+
Browser Independent
Install with
Release notes - Version 1.0.0-beta2
  • Remove banner.txt, this time for sure