Disable link within a container


trying to disable a link within a container dynamically does not behave as expected. When putting a Vaadin Link inside a component container and setting it dynamically with setEnabled(false) the link is shown disabled but is still clickable.

The following example demonstrates this behaviour.

    protected void init(VaadinRequest request) {
        VerticalLayout layout = new VerticalLayout();

        Link link = new Link("Click Me!", new ExternalResource("http://vaadin.com/"));
        VerticalLayout vlayout = new VerticalLayout();

        Button toggleLinkButton = new Button("enable/disable link");
        toggleLinkButton.addClickListener(e -> link.setEnabled(!link.isEnabled()));
        Button toggleContainerButton = new Button("enable/disable container");
        toggleContainerButton.addClickListener(e -> vlayout.setEnabled(!vlayout.isEnabled()));
  1. The first button disables the link and behaves as expected.
  2. The second button disables the VerticalLayout. The link is shown disabled but is still clickable by the user.

Tested with Vaadin 7.5.x and different browsers.

How can I achieve that the link is locked and is not responding to a user click when the component container is disabled?

Is there reason why you couldn’t do 1. and 2. at the same time in one event?

Hi Tatu,

thank you for your quick reply. Let’s say I want to lock the whole screen for user interaction. The easiest way is to disable the component container. Another solution would be to iterate through all elements and disable each of them. The problem is that I don’t see a general way how to access the childrens of the surrounding container.

I disable the container with:


By the way a Button is disabled and locked when disabling the component container.

The documentation says that all components are disabled recursively:


Any hint how to access the childrens or how to disable the links?

In case of component containers, such as layouts, there is HasComponent nested class, which has iterator.

I need to check the documentation in more detail. It maybe that you have found a bug.

I created Trac ticket for this.