use of com.haulmont.cuba.gui.components.DateField in project cuba by cuba-platform.
the class DateFieldDsTest method testUnsubscribeDsListener.
@Test
public void testUnsubscribeDsListener() {
DateField dateField = (DateField) factory.createComponent(DateField.NAME);
Datasource<User> userDs = getTestUserDatasource();
User user = userDs.getItem();
Date updateTs = new Date();
user.setUpdateTs(updateTs);
dateField.setDatasource(userDs, "updateTs");
// unbind
dateField.setDatasource(null, null);
Datasource.ItemPropertyChangeListener<User> propertyChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
userDs.addItemPropertyChangeListener(propertyChangeListener);
dateField.setValue(new Date());
assertEquals(updateTs, user.getUpdateTs());
}
Aggregations