URL Parameter Mapping for Vaadin Flow

\u0000\uD83D\uDC49 [Add-on page in Directory]
(https://vaadin.com/directory/component/url-parameter-mapping)\n\n\uD83D\uDC49 [Samples in Directory]
(https://vaadin.com/directory/component/url-parameter-mapping/samples)\n\n\uD83D\uDC49 [Source code]
(https://github.com/fluorumlabs/url-parameter-mapping)\n\n\uD83D\uDC1E [Issue tracker]
(https://github.com/fluorumlabs/url-parameter-mapping/issues)\n\n# URL Parameter Mapping for Vaadin Flow\n\nWhile https://github.com/vaadin/flow/issues/2740 and \nhttps://github.com/vaadin/flow/issues/4213 are still in the works, \nthe need for flexible parametrized routes still exist. This\nhelper implementation lives on top of built in HasUrlParameter\nand provides support for named parameters.\n\nSimple usage example:\njava\nimport org.vaadin.flow.helper.*;\n\n...\n\n@Route(\"example\")\n@UrlParameterMapping(\":exampleId/:orderId\")\n// Will match /example/12345/ORD223434, set exampleId = 12345 and\n// call setOrder(\"ORD223434\")\n// Otherwise user will be rerouted to default NotFoundException view\nclass MyView extends Div implements HasUrlParameterMapping {\n // Note: parameter fields/setters should be public \n @UrlParameter\n public Integer exampleId;\n \n @UrlParameter(name = \"orderId\", regEx = \"ORD[0-9] {6}\") \n public setOrder(String order) { ... }\n ...\n}\n \n\nThe following features are implemented:\n- Support for Integer, Long, Boolean, String and UUID properties (with automatic regular expression checks)\n- Parameter placeholders: order/:orderId\n- Optional parameters: order/:orderId [/:rowId]\n- Parameters in the middle of path: order/:orderId/edit\n- Multiple alternative mappings\n- Automatic rerouting to custom view if nothing matches.\n- Inline regular expressions: forum/thread/:threadId/.*\n- Custom regular expressions: @UrlParameter(regEx = \"overview|samples|links\")\n- Dynamically computed regular expressions for parameters\n- RequestHandler support\n- URL formatting\n- Query parameters support\n\n

Hi,

I have the following route:

@RoutePrefix(Application.APPLICATION_NAME) //assume value is 'foo'
@Route(value = "login")
@PageTitle(TextSource.APPLICATION_NAME_FOR_USER)
@UrlParameterMapping("
[/:parameter]")
public class LoginView extends VerticalLayout implements Serializable, HasLogger, HasUrlParameterMapping {

And in this View I have the following setter method:

    @UrlParameter(name = "parameter")
    public void setParameter(String parameter) {
        this.parameter = parameter;
    }

As far as I understand the examples the parameter now should be optional and the following URL should be possible:

http://localhost:8080/foo/login

But unfortunately I get routed to the NotFoundException-View and cannot open my view without the parameter.
It seems that the method matchAndReroute always appends the “/?&” to the path and therefore the matcher cannot handle it in the correct way.

I use:

        <dependency>
            <groupId>org.vaadin.helper</groupId>
            <artifactId>url-parameter-mapping</artifactId>
            <version>1.0.0-alpha7</version>
        </dependency>

Can anyone help please?

What would be the approach if I want to update the parameters in the url from code?

Imagine I have a ComboBox where I want to preserve the selected value in the url so that the user can e.g. refresh the page or share the link. Do I have to call the url each time a value change happens using the new parameter in the url string?