disabling a RouterLink

Hi,
I am new to Vaadin and am getting back into Java after a number of years. Kind of rusty so I hope my questions aren’t too lame. I have created a menuBar and am trying to set a RouterLink to disabled if a condition is not met. I tried myRouterLink.setEnabled(false), but that did not work. I see the method setHighlightAction() and was wondering if this would be appropriate and what are acceptable values to pass in. I appreciate your help.

Tony

Hi,

I think that’s a fair assumption, but at least right now, you can’t “disable” router links as such, any more than you can “disable” the navigating functionality in plain old <a> elements in HTML (and this is because RouterLinks are just that, slightly enhanced Anchor elements). One thing you can do as a workaround is the same thing you can do with <a> elements, which is removing the href attribute, like this: routerLink.getElement().removeAttribute("href");. Another option would be CSS tricks, but they’re not as foolproof.

-Olli

Olli,
Thanks very much. That makes sense. It worked. Appreciate your help!

Tony

Great to hear!