Dear CUBA team,
I’m trying to use property change listener to track property value. But I found for dynamic attributes, the old value is replaced by “null”. It’s a little confusing, as there is no other way to find old value.
com.haulmont.cuba.core.entity.BaseGenericIdEntity#setValue
if (newValue == null) {
if (categoryAttributeValue != null) {
categoryAttributeValue.setValue(null);
categoryAttributeValue.setDeleteTs(AppBeans.get(TimeSource.class).currentTimestamp());
propertyChanged(property, oldValue, null);
}
} else if (!ObjectUtils.equals(oldValue, newValue)) {
if (categoryAttributeValue != null) {
categoryAttributeValue.setValue(newValue);
categoryAttributeValue.setDeleteTs(null);
} else {
Metadata metadata = AppBeans.get(Metadata.NAME);
ReferenceToEntitySupport referenceToEntitySupport = AppBeans.get(ReferenceToEntitySupport.class);
categoryAttributeValue = metadata.create(CategoryAttributeValue.class);
categoryAttributeValue.setValue(newValue);
categoryAttributeValue.setObjectEntityId(referenceToEntitySupport.getReferenceId(this));
categoryAttributeValue.setCode(attributeCode);
DynamicAttributes dynamicAttributesBean = AppBeans.get(DynamicAttributes.NAME);
categoryAttributeValue.setCategoryAttribute(
dynamicAttributesBean.getAttributeForMetaClass(getMetaClass(), attributeCode));
dynamicAttributes.put(attributeCode, categoryAttributeValue);
}
propertyChanged(property, null, newValue);
}
Is this a defect?
Thanks for your time