Hi,
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.
@Override
protected void init(VaadinRequest request) {
VerticalLayout layout = new VerticalLayout();
Link link = new Link("Click Me!", new ExternalResource("http://vaadin.com/"));
link.setTargetName("_blank");
VerticalLayout vlayout = new VerticalLayout();
vlayout.addComponent(link);
layout.addComponent(vlayout);
Button toggleLinkButton = new Button("enable/disable link");
toggleLinkButton.addClickListener(e -> link.setEnabled(!link.isEnabled()));
layout.addComponent(toggleLinkButton);
Button toggleContainerButton = new Button("enable/disable container");
toggleContainerButton.addClickListener(e -> vlayout.setEnabled(!vlayout.isEnabled()));
layout.addComponent(toggleContainerButton);
setContent(layout);
}
- The first button disables the link and behaves as expected.
- 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?