Directory

URL Parameter Mapping - Vaadin Add-on Directory

Flexible URL parameter mapping for Vaadin Flow URL Parameter Mapping - Vaadin Add-on Directory
# 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: ```java 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
Source Code
Discussion Forum
Issue tracker

URL Parameter Mapping version 1.0.0-alpha1
Initial pre-release

URL Parameter Mapping version 1.0.0-alpha2
- Added `isPatternMatched()` and `isPatternMatched(pattern)` methods to `HasUrlParameterMapping` and `HasAbsoluteUrlParameterMapping` - Added support for `UUID` properties - [!] Breaking change: automatically reroute to default `NotFoundException` view if no matches found - Added `@RerouteIfNotMatched` annotation to change the default exception class - Added `@IgnoreIfNotMatched` annotation to disable automatic rerouting - Fixed regular expressions for `Integer` and `Long` properties

URL Parameter Mapping version 1.0.0-alpha3
- Added support for fields - Added `@UrlParameter` annotation with optional cutom regEx - Fixed broken patterns for optional parameters with custom regRx - Removed `commons-beanutils` dependency

URL Parameter Mapping version 1.0.0-alpha4
- (breaking change) Added `@UrlMatchedPatternParameter` replacing `isPatternMatched` - Added support for dynamic regular expressions - Added support for `RequestHandler`

URL Parameter Mapping version 1.0.0-alpha5
- Fixed exception when clearing parameter - Fixed mismatches when optional segment is at first position of pattern - [breaking change] Added rerouting to view in addition to exception based error rerouting

URL Parameter Mapping version 1.0.0-alpha6
- Added URL formatting

URL Parameter Mapping version 1.0.0-alpha7
- Added support for query parameters

URL Parameter Mapping version 1.0.0-beta1
- Removed `banner.txt`

URL Parameter Mapping version 1.0.0-beta2
- Remove `banner.txt`, this time for sure