Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Enable/Disable button on selection of ComboBox in the grid Vaadin 8
I have Vaadin 8 grid and in the grid One column has button and other column has combo box. Now, I need to enable/disable button on selection of value in the combo box of the same row. Is that possible. if yes, then how?
Here's an example:
public class MyUI extends UI {
public static class MyBean {
public boolean isButtonEnabled() {
return buttonEnabled;
}
public void setButtonEnabled(boolean buttonEnabled) {
this.buttonEnabled = buttonEnabled;
}
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
private boolean buttonEnabled = true;
private String s;
}
@Override
protected void init(VaadinRequest vaadinRequest) {
Grid<MyBean> grid = new Grid<>();
MyBean f1 = new MyBean();
f1.setS("fff");
MyBean f2 = new MyBean();
f2.setS("uuu");
grid.setItems(f1, f2);
grid.addComponentColumn(myBean -> {
ComboBox<String> comboBox = new ComboBox<>();
comboBox.setItems("Item 1", "Item 2");
comboBox.addValueChangeListener(e -> {
myBean.setButtonEnabled(!myBean.isButtonEnabled());
grid.getDataProvider().refreshItem(myBean);
});
return comboBox;
});
grid.addComponentColumn(myBean -> {
Button button = new Button("Click me", e -> {
Notification.show("You could click the Button");
});
button.setEnabled(myBean.isButtonEnabled());
return button;
});
this.setContent(grid);
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}
}
**Thanks Olli for providing solution. **
Just a little change in code above: Button enabling/disabling functionality is working fine but combo box's value is not getting updated. So, I have added new attribute selectedComboVal in myBean and assigned value of/to combo box.
**Before calling listener: comboBox.setSelectedItem(myBean.getSelectedComboVal());
In listener: myBean.setSelectedComboVal(comboBox.getValue());**