Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router: support multiple routes for the same component #2741

Closed
vlukashov opened this issue Oct 20, 2017 · 7 comments
Closed

Router: support multiple routes for the same component #2741

vlukashov opened this issue Oct 20, 2017 · 7 comments
Assignees
Labels
Milestone

Comments

@vlukashov
Copy link

When defining a routes map of an application, as a developer, I want to define multiple routes for some views (e.g. both / and /storefront should be handled by the same view).

With the new Router API that is not supported at the moment (flow-1.0.0.alpha6).

A workaround exists:

@Route("")
public class DefaultView extends Div implements BeforeNavigationListener {

	@Override
	public void beforeNavigation(BeforeNavigationEvent event) {
		event.rerouteTo(StorefrontView.class);
	}
}
@caalador
Copy link
Contributor

How would Router::getUrl work in the case of multiple route targets?
As a change having @Route(value = {"", "storefront"}) shouldn't be a big problem, but when you want to for instance get the url for the navigation target which route should be returned?
Does it matter?

@vlukashov
Copy link
Author

This question was already discussed in the scope of the old Router API. I guess, the conclusions are quite relevant still: #1476

@Legioth
Copy link
Member

Legioth commented Oct 24, 2017

I'd suggest introducing something like a repeatable @RouteAlias annotation with some suitable parameters (at least the same as @Route, but also some way of defining that value should be interpreted relative to the prefix of some other navigation target or router layout).

URL generation would thus always be based on @Route and @RouteAlias would only be used for supplementing the resolving functionality.

@pleku pleku added the routing label Oct 25, 2017
@denis-anisimov denis-anisimov self-assigned this Nov 7, 2017
@pleku
Copy link
Contributor

pleku commented Nov 8, 2017

There could be an additional parameter @RouteAlias(value="/some/path", redirect=true) that will make Flow replace url in the browser to the one that was set in the @Route("the_path") for that view.

@denis-anisimov
Copy link
Contributor

The last comment justifies the reason of having @RouteAlias annotation instead of making @Route repeatable.
But it should be done as a separate ticket #2870.

@ghost
Copy link

ghost commented Nov 8, 2017

What happens if the route target is meant to support wildcard parameters but only on some URL patterns?

E.g given a route target like this, I want Flow to match the context root and "home/whatever" but not "profile/whatever"

@Route("")
@Route("home")
class MyRoute implements HasUrlParameter<String>

@Legioth
Copy link
Member

Legioth commented Nov 13, 2017

@sayo-vaadin A navigation target has one route and 0 - n aliases. If you want to make different aliases work in different ways, then you'd probably have to define those as distinct navigation targets that just happen to use the same contents.

vlukashov pushed a commit to vaadin/bakery-app-starter-flow-spring that referenced this issue Nov 29, 2017
remove the workaround for the Flow issue vaadin/flow#2741 that was added in the PR #210

Jira: BFF-352
johannesh2 pushed a commit to vaadin/bakery-app-starter-flow-spring that referenced this issue Nov 29, 2017
…299)

remove the workaround for the Flow issue vaadin/flow#2741 that was added in the PR #210

Jira: BFF-352
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants