05-25-2019 06:09 PM
I'd like to ensure that a given property is always set as uppercase string.
I tried to use a java Behavior to update property value before commit, but this has no effect (see below).
Any
behavior declaration:
<code>
eventManager.bindClassBehaviour(
NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME,
myModel.myAspect,
new JavaBehaviour(this, "onUpdateProperties", Behaviour.NotificationFrequency.FIRST_EVENT)
);
...
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) {
// modifying property value of 'after' map has no effect
}
</code>
Idea suggestion ?
Thanks
05-27-2019 04:00 AM
Modifying the after map NEVER has any effect. The after map is just a shallow copy of the node properties state provided to the behaviour - it does not allow for direct mutation. You have to use the NodeService to make actual, persistent changes to nodes from within your behaviour.
05-27-2019 06:26 AM
OK. I'd like to apply some string 'normalization' to specific properties when set by the user in UI (either share or any other external custom UI).
I was thinking about using behaviors to do that: 1) test if the value set is a normalized value, if not reset the value with the normalize value (which will trigger again the behavior….).
Do you think there's a more efficient way to do that ?
Explore our Alfresco products with the links below. Use labels to filter content by product module.