Showing posts with label alfresco share 4. Show all posts
Showing posts with label alfresco share 4. Show all posts

Thursday, March 15, 2012

Adding your custom action in documentLibrary - alfresco share 4

Many times we need our own custom action to be called through documentLibrary browse actions (folder actions) Below are the customization points to achieve it in alfresco 4.

Note: we are adding custom action called "Create Custom Code"

1) share-config-custom.xml
This file is the entry point to customization in share. Lets add our configuration here to add our action.
<config evaluator="string-compare" condition="DocLibActions">
 <actions>
 <action id="folder-custom-action" type="javascript" icon="folder-manage-permissions" label="Create Custom Code">
    <param name="function">callYourCustomFunction</param>
            </action>
 </actions>
 <actionGroups>
 <actionGroup id="folder-browse">
 <action index="161" id=" folder-custom-action " />
 </actionGroup>
 </actionGroups>
 </config>




Note : Here we need to analyse that callYourCustomFunction is the function we would write our own inside /components/documentlibrary/actions.js
write your custom code in that file or call repository side webscript to achieve your goal.


 EnJOY !!

Wednesday, March 14, 2012

Create new evaluator in documentLibrary Action - alfresco 4 share

To create our custom evaluator we need to configure following files :
1) share-config-custom.xml
2) custom-slingshot-application-context.xml

For example let I will create my one custom action called "Start Draft Workflow" in specified type of content only and checking specified properties in it.

Step 1:  Configure first custom action and actionGroup (share-config-custom.xml)
====================================================================
<config evaluator="string-compare" condition="DocLibActions"> <actions> 
<action id="folder-assign-workflow" type="javascript" icon="folder-manage-permissions" label="Start Draft Workflow">
<param name="function">onActionAssignWorkflow</param>
<evaluator>evaluator.doclib.action.draftTypeFolder</evaluator>
</action>
</actions>
<actionGroups>
<actionGroup id="folder-browse">
<action index="161" id="folder-assign-workflow" />
</actionGroup>
</actionGroups>
</config>


Step 2:  Configure bean entry in slingshot context file for evaluator (custom-slingshot-application-context.xml)
=====================================================================
<bean id="evaluator.doclib.action.draftTypeFolder" class="com.clms.web.evaluator.CLMSActivateDraftWorkflowEvaluator" > </bean>
Step 3:  Create java class for evaluator (CLMSActivateDraftWorkflowEvaluator.java)
Step 4:  Finally put jar at share/WEB-INF/lib
Finally we need to take care that this evaluator can only find our jar, unless we provide jar to share class path. so through your ant build, copy alfresco/WEB-INF/lib/<custom-jar> to share/WEB-INF/lib/<custom-jar>




ENJOY !!

Tuesday, March 13, 2012

Custom Document Library Action Evaluator


Custom Evaluator for Document Library Action

Sometimes we need to show certain custom action on specified type of content only. Not all content show that custom action, because we need to evaluate to certain actions only.

This example explain simple custom evaluator in alfresco 4 share document library in which I want to display my custom action only on clm:Draft kind of type content only.

To make this enable we need to modify following files:
  1. share-config-custom.xml
  2. custom-slingshot-application-context.xml

  1. share-config-custom.xml
This file contains custom action and actionGroup entry.
Action entry contains information about the new custom link we are adding to action like below:

<actions>
<action id="folder-assign-workflow" type="pagelink" icon="folder-manage-permissions" label="Start Draft Workflow">
<param name="page">documentlibrary?nodeRef={node.nodeRef}</param>
<evaluator>evaluator.doclib.action.draftTypeFolder</evaluator>
</action>
</actions>

ActionGroup is the group in which we are adding our custom action entry
<actionGroups>
<actionGroup id="folder-browse">
<action index="161" id="folder-assign-workflow" />
</actionGroup>
</actionGroups>

So total entry looks like below :

<config evaluator="string-compare" condition="DocLibActions"> 
<actions> 
<action id="folder-assign-workflow" type="pagelink" icon="folder-manage-permissions" label="Start Draft Workflow"> 
<param name="page">documentlibrary?nodeRef={node.nodeRef}</param> 
<evaluator>evaluator.doclib.action.draftTypeFolder</evaluator> 
</action> 
</actions> 
<actionGroups> 
<actionGroup id="folder-browse"> 
<action index="161" id="folder-assign-workflow" /> 
</actionGroup> 
</actionGroups> 
</config>
  1. custom-slingshot-application-context.xml
This file contains evaluator entry.

<bean id="evaluator.doclib.action.draftTypeFolder" parent="evaluator.doclib.action.nodeType">
<property name="types">
<list>
<value>clm:Draft</value>
</list>
</property>
</bean>