Jared Ottley

Technology | Fatherhood | Insanity

Alfresco: Property Decorators — cont.

with 4 comments

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>

Written by jared

April 2nd, 2012 at 2:26 pm

Posted in Alfresco

Tagged with

4 Responses to 'Alfresco: Property Decorators — cont.'

Subscribe to comments with RSS or TrackBack to 'Alfresco: Property Decorators — cont.'.

  1. [...] we need to add it to the list of propertyDecorators.  Update: I’ve add a new post that covers how the mapping should occur and added a new bean here. Currently this requires [...]

  2. Thats quite a good improvement – I wasn’t aware of the Spring merge feature. But how to support more than one property decorator in a multiple-module-extension scenario? Maybe introduce a registry pattern and allow also new properties to be created in the json response?

    Regards,
    lothar

    Lothar Märkle

    3 Apr 12 at 11:05 am

  3. That is a good question. I haven’t looked to see what would happen in that situation. If it doesn’t work…then I think we would have to investigate using a registry.

    jared

    3 Apr 12 at 11:11 am

  4. I suggested a workaround to this issue in my blog: http://thinkalfresco.blogspot.de/2012/05/augmenting-alfresco-spring-bean.html

    Lothar Märkle

    21 May 12 at 10:33 am

Leave a Reply