Add 2 fields in entity - boolean "required" and String "name"
Add following Bean
@Component(SampleAttributeAccessHandler.NAME)
public class SampleAttributeAccessHandler implements SetupAttributeAccessHandler<Sample> {
public static final String NAME = "applysecuritysample_SampleAttributeAccessHandler";
@Override
public void setupAccess(SetupAttributeAccessEvent<Sample> event) {
if (BooleanUtils.isTrue(event.getEntity().getRequired())) {
event.addRequired("name");
}
}
@Override
public boolean supports(Class clazz) {
return clazz.isAssignableFrom(Sample.class);
}
}
Create browser and editor screen for entity.
Open editor screen controller and generate handler for ItemPropertyChange event for entity Dc.
Add following code in handler
attributeAccessSupport.applyAttributeAccess(this, true, getEditedEntity());
Run application and try to create entity. Check "required" field and input name.
Save entity.
Expected result: entity saved without any errors
Actual result: "Unable to save object" message appears
Most likely reproduced only if attributeAccessSupport applied in ItemPropertyChange event of entity’s DC.
Platform version: 7.2.13 https://www.cuba-platform.ru/discuss/t/oshibka-pri-ispolzovanii-attributeaccesssupport-applyattributeaccess/5642
Create browser and editor screen for entity.
Open editor screen controller and generate handler for ItemPropertyChange event for entity Dc.
Add following code in handler
attributeAccessSupport.applyAttributeAccess(this, true, getEditedEntity());
Run application and try to create entity. Check "required" field and input name.
Save entity.
Expected result: entity saved without any errors Actual result: "Unable to save object" message appears
Most likely reproduced only if attributeAccessSupport applied in ItemPropertyChange event of entity’s DC.