HasUrlComponent#setParameter is invoked clicking on self-referencing links
See original GitHub issueThe setParameter
method of HasUrlComponent
gets invoked even if the user is already in there; this means all the operations the method does with the parameter are executed again for the same component instance. For example:
public class MainLayout extends VerticalLayout implements RouterLayout {
public MainLayout() {
add(new RouterLink("One", Foo.class, 1);
add(new RouterLink("Two", Foo.class, 2);
add(new RouterLink("Three", Foo.class, 3);
}
}
@Route(value = "foo", layout = MainLayout.class)
public class FooCard extends VerticalLayout implements HasUrlParamenter<Long> {
@Override
public void setParameter(BeforeEvent event, Long parameter) {
composeLayoutFor(parameter);
}
}
If the user is at /foo/1
and clicks on link “One”, composeLayoutFor
is invoked for the same instance even if the location does not change, for example duplicating components that the method might add (which depends on the parameter value).
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
GraphQL Engine server config reference - Hasura
GraphQL Engine server config reference. Introduction. Every GraphQL engine command is structured as: $ graphql-engine <server-flags> serve <command-flags>.
Read more >graphql – CSS-Tricks
We imported the Link component from Gatsby and then wrapped the post title with the Link component and reference the slug of the...
Read more >sitemap-questions-84.xml - Stack Overflow
... .com/questions/1750757/restarting-a-self-updating-python-script 2020-12-02 ... /questions/5948205/chrome-open-link-in-new-tab-not-firing-the-click-event ...
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
Should probably also consider in https://github.com/vaadin/spring/issues/263 that it should be possible to always create a new view instance on navigation for Spring too. Maybe when
prototype
scope is used ?Making it configurable e.g. through the
@Route
annotation sounds like a good way to go. I guess the API would then be something like@Route(value = "foo", reuseInstance = false)
. Should preferably also take router layouts into account since those are also reused using the same mechanism.I think the comment about Spring can be disregarded. The original router prototype implementation delegated the decision whether to reuse an instance or create a new one to Spring, but the current implementation always reuses based on the code snippet referenced in the above comment.