
Extending an AssetRendererFactory
In many projects we find that developers need to extend the behaviour of the AssetRendererFactories to fit their needs, and, even it is not that hard, it takes a while to think on the best and cleaner way to achieve this.
In this article I'll be using UserAssetRendererFactory as an example
1.- Create an ext plugin (in the Liferay IDE: File - new - Liferay Portlet - ext)
2.- Add the portlet you want to modify/extend to liferay-portlet-ext.xml
In our example:
<portlet>
<portlet-name>11</portlet-name>
[...]
<asset-renderer-factory>com.myfactory.MyUserAssetRendererFactory</asset-renderer-factory>
[...]
</portlet>
3.- Create a class that extends the original AssetRendererFactory and the add or modify the methods we need
(Example)
package com.liferay.portlet.directory.asset;
import com.liferay.portlet.directory.asset.UserAssetRendererFactory;
public class MyUserAssetRendererFactory extends UserAssetRendererFactory {
public boolean isLinkable() {
return true;
}
public boolean isSelectable() {
return true;
}
}
4.- Deploy, restart the server and you are ready to go! :)
Juan Fernández
Related information: Asset Framework