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>
[...] 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 [...]
Alfresco: Property Decorators at Jared Ottley
2 Apr 12 at 2:33 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
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 edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
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 edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
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 edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>