Alfresco: Property Decorators — cont.

In my post on Property Decorators I pointed out that there was an issue adding a customer property decorator: you couldn’t create a custom bean to perform the mapping and had to overwrite the out of the box bean. Well Mike Hatfield has found a solution which is just awesome: Map Merge.

It is possible to merge maps of a child bean to a parent bean. Here is how it is done: Create a new bean, where the parent is the applicationScriptUtils bean. Add a single property of decoratedProperties and define a map in the property. When you define the map add the attribute merge="true". Finally, add your custom property to decorator bean mappings. Done!

Here is an example:

<bean id="customApplicationScriptUtils" parent="applicationScriptUtils">
   <property name="decoratedProperties">
      <map merge="true">
         <entry key="alf:propertyHolder">
            <ref bean="customDecoratorBean"/>
         </entry>
      </map>
   </property>
  </bean>