flow
flow copied to clipboard
circular dependency bug while using layouts
Description of the bug
I have a MainLayout and some other routes which are child of MainLayout. I have a drawer in MainLayout which has RouterLinks to those child routes. Now the issue is I have to mention class names of child layouts while creating the RouterLinks in MainLayout. And I have to mention MainLayout.class as layout parameter in Route annotation in child view classes. So it is causing circular dependency. So is there any way to remove this circular dependency
Expected behavior
Sonar should not give circular dependency bug here
Minimal reproducible example
Just create a MainLayout add RouterLinks to it and add MainLayout.class as layout parameter in Route annotation in child view classes
Versions
- Vaadin / Flow version: 14.11.0
- Java version: 11
- OS version: MacOS Ventura 13.6.1
- Browser version (if applicable):
- Application Server (if applicable):
- IDE (if applicable):
Well.. you are adding that direct reference yourself.. you can get all available routes from the RouterRegistry if you are worried about Sonarqube and go the full generic "route".
Can you please tell me how to do it? I want to create RouterLink for each view in MainLayout, so how to use RouterRegistry for it?
https://vaadin.com/docs/latest/routing/dynamic#getting-registered-routes-and-listening-for-changes
Thanks
I tried it but it doesn't solve circular dependency bug. This solution is good to remove class references from MainLayout but in child classes still MainLayout reference is there
That's not called "circular".
AtRoute
indeed needs a layout component class as a parameter, but I don't think this means the circular dependency in terms, for example, how Maven treats it.
This is more like a logical binding of your routes and main layout.
We don't know what we can do in Flow to address the issue that Sonar gives you. Proposed for closure.
If you have more details from Sonar that could give us more insights, please provide it to us.