@Route and HasUrlParameter

Hello,

Anyone can tell me if I can build URLs like this with @Route?
/companies/#param#/users/#param#

As far as I could understand, HasUrlParameter only allows me to have a parameter at the end of the URL.

As far as I could understand, HasUrlParameter only allows me to have a parameter at the end of the URL.

Yes. That is correct.

Lets think /companies/#param1#/users/#param2#

However Router allows to have multiple parameters. So you could think “users” as parameter as well. Which means that if you have setParameter(…) method in the companies view, you need to use @WildcardParameter annotation

@Override
public void setParameter(BeforeEvent event,
        @WildcardParameter String parameter) {
		...

And the parse parameter by splitting it by “/”. So you can pick “users” as parameter and navigate to it. If you need to pass “param1” to to users. You probably need to navigate to: /users/#param1#/param2#

And naturally then in users view you need to have HasUrlParameter as well in order to process the last parameter.

The above could work if your parameters do not produce difficult conflicting path names.