use of com.haulmont.cuba.gui.components.CheckBox in project cuba by cuba-platform.
the class CheckBoxDsTest method testUnsubscribeComponentListener.
@Test
public void testUnsubscribeComponentListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
checkBox.setDatasource(userDs, "active");
// unbind
checkBox.setDatasource(null, null);
Component.ValueChangeListener valueChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
checkBox.addValueChangeListener(valueChangeListener);
user.setActive(false);
assertEquals(true, checkBox.getValue());
}
Aggregations