Format property before commit using Behavior

Showing results for 
Search instead for 
Did you mean: 
Established Member

Format property before commit using Behavior

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). 


behavior declaration:


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



Idea suggestion ?


2 Replies

Re: Format property before commit using Behavior

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.

Established Member

Re: Format property before commit using Behavior

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 ?