Making SideNavItems visible by config

I created a test app with start.vaadin.com and used the AppLayout with a couple of views. The generated code creates a SideNav which is filled with MenuEntries which are automatically created from all views with @Menu annotation.

I want some of the menu entries to be invisible (and the views not be reachable) initially. Only after some user action (e. g. perform a search) the other menu entries shall become visible.

Is there a way to make this somehow generic, e. g. let the MenuEntry check for a property/lambda expression/etc. if it should be visible? Or do I have to explicitly put that in code?

Code it is. The default auto generated sidebar is not really meant for advanced uses imho

Okay, thanks. That was my impression, too, but sometimes you start hacking away and when you’re done you find a much simpler solution. :wink:

Follow-up question: How can I access the layout when being inside the view? Or what would be the recommended way to access the SideNav?

Let’s say… I know ways but I would recommend not to do it like this. Accessing the outer shell feels dirty. I would recommend to use How do I communicate between components attached to one UI - Vaadin Cookbook and make your main layout aware of a custom event and throw that event at appropriate moments

1 Like

Thanks, Christian! I agree, that’s probably the best way.