Router: Multiple optional parameters support
See original GitHub issueAs a developer I want to have the same view being accessible using different routes with different parameters. For example:
/forum/thread/<threadId>
opens the thread view/forum/thread/<threadId>/<messageId>
opens the same thread view and scrolls to specified message/forum/message/<messageId>
– same as above, but retrieves thethreadId
first, based onmessageId
In current implementation we have
@Route(value = FORUM_THREAD_ROUTE /* /forum/thread */, layout = ForumView.class)
@RouteAlias(value = FORUM_MESSAGE_ROUTE /* /forum/message */, layout = ForumView.class)
and then
@Override
public void setParameter(BeforeEvent event, @WildcardParameter String parameter) {
if(StringUtils.isNotEmpty(parameter)) {
if (event.getLocation().getPath().startsWith(FORUM_THREAD_ROUTE)) {
String[] segments = parameter.split("/");
if (segments.length >= 1) threadIdParam = segments[0];
if (segments.length >= 2) messageIdParam = segments[1];
} else {
String[] segments = parameter.split("/");
if (segments.length >= 1) messageIdParam = segments[0];
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Multiple Optional Params in React Router - Stack Overflow
I've got a situation where I need to support the following use case. I've got React component that is accessed via /project/1234 ....
Read more >How can i pass more one optional parameter in the route
i am trying to pass more then one optional Parameter in my route. Copy Code 'middleware' => 'auth:api', 'prefix' => 'api/v1' ], function...
Read more >Multiple optional parameters in the url - MSDN - Microsoft
User208219337 posted. I am working on an MVC app. I have to return the images based on the parameters passed in the URL....
Read more >Passing Optional Parameters to a Route - Rangle.io
Query parameters allow you to pass optional parameters to a route such as pagination information. ... The key difference between query parameters and...
Read more >Optional route parameters - Blazor University
Optional route parameters aren't supported explicitly by Blazor, but the equivalent can be easily achieved by adding more than one @page declaration on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, that’s me, the OP
There is now an implementation available as extension to Vaadin Flow by @fluorumlabs : https://vaadin.com/directory/component/url-parameter-mapping