We had discussed about Alfresco Share and its architecture in previous articles. We had also discussed about recent changes in Alfresco share architecture and its advantages. There I had pointed out that those changes in architecture will make developers life easy as it will be lot easier to customize user interface. In this article, I am going to explain how we can show and hide existing Alfresco share components conditionally. Other possible customizations are overriding the existing webscripts which are generating particular components. So in short this will give full freedom to developers to extend those subcomponent modules as per their needs.
For instance if we have a requirement where we want to hide certain components from particular set of users we can easily do it with the help of new module extension feature. In this case we will hide some of the components of document details page for certain groups.
Enable surf bug (powerful tool developed by alfresco team for developers) though Alfresco share webscript page
Go to document detail page and click on the area which you want to hide for example version detail, workflow history on right hand side of document detail page. You will be able to see the components details from which we need to note down following
|ID:||The id of the Sub-Component – this is always prefixed by the parent Component id and a “#” indicates the start of Sub-Components identification|
Based on details collected in step2 we need to create xml file where we will define module which we want to extend. Here I have added my custom evaluator class for that module that means version detail panel will be shown to all the users conditionally. Evaluators for modules are similar to evaluator of actions but both are not same as both of them follow different hierarchy. Module evaluator class extends
org.springframework.extensions.surf.extensibility.impl.DefaultSubComponentEvaluator class and override evaluate(RequestContext context, Map<String, String> params) method as you can see I have passed parameter to evaluator similarly you can pass as many parameters you like to make your evaluator more configurable and flexible. In this case I am passing group name for which I want this version history panel to be visible for all rest of the users it will be disable.
Restart the server and go to module deployment console
You will be able to see “Evaluate version Panel” module in available module box you need to deploy it by moving it in deployed module and click apply.
Now go to document detail page of any of the document in alfresco repository. Check with one of the non admin user you will not be able to see version history panel.
For more information on Extension module deployment and packaging you can refer this blog alfresco-share-extension-module .Hope this will give you good insight of extensibility module usage. This is really an amazing feature of alfresco share so I recommend you to explore this.