Search This Blog

About Me

Highly experienced in implementation and customization of Alfresco. More than 11 years of experience working on Alfresco, versions ranging from 2.x to 5.x. Successfully processed innovative and tailored CMS solutions to meet ever-changing business requirements for multiple clients. Role Includes : Experience in Alfresco Upgrades, SOLR migration, Proposals, Team Handling, Delivery, Content Migration, POC's etc.. Extensive experience in client co ordination, working on offshore-onshore model and project take over. Technical Expertise Includes : Java, JSP, Servlet, JSF, JavaScript, AJAX, Spring, SQL, Hibernate, Web Services(REST). Specialities Includes : Content Migration, Product Customization, Business CMS Solutions, Workflow, Project Transition.

Thursday, April 15, 2010

Adding a custom action in alfresco action column of the content and in view details page


Whenever you want to add any kind of action link into alfresco, you need to make changes into 'web-client-config-actions.xml' or 'web-client-config-actions-custom.xml'.

As alfresco says, it's better to make changes in custom file as it keeps you code separate from alfresco and is easy for debugging also.
Suppose you want to add an action 'Approved' for particular document.
You want this action to appear in actions column and in view details of your content.
Below are the steps of doing this

  1. Define an action in web-client-config-actions-custom.xml (here after we will mention it as 'actions-custom.xml') inside <alfresco-config> and <config> tags
    I am providing the whole action tag with description of each tag

<action id="approveDoc"> - A valid ID for your action
    <permissions>
       <permission allow="true">Write</permission> - Default Permissions
   </permissions>

<label>Profile Review Complete</label> - Label to display when you put your mouse over the action text

<label-id>approve_document</label-id> - Name to appear in JSP
   <image>/images/icons/green_tick.gif</image> - Icon to appear in JSP
  <action-listener>
            #{[YOUR BEAN NAME].[METHOD TO CALL]} – Bean method to call when action is performed
   </action-listener>
   <action>[Outcome]</action> - This is to navigate the page when action is completed
   <params>
       <param name="id">#{actionContext.id}</param> - Specifically for getting the node ref from context id
   
</params>
</action>

  1. Define an action-group in actions-custom.xml inside <alfresco-config> and <config> tag

    This action group name will need to be used for displaying the actions in JSP file

    /* For Actions column */
    <action-group id="approve_doc_actions_browse">
       <show-link>false</show-link>
       <style-class>inlineAction</style-class>
       <action idref="approveDoc" />
    </action-group>

    /* For view details page*/

    <action-group id="approve_doc_actions_details">
           <action idref="approveDoc" /> - The action which we have defined above
        
    </action-group>

3. Use below tag to display the action into the actions column of the content in browse page

<%-- Content Actions column --%>

<a:column id="fo_col18" actions="true" style="text-align:left"
rendered="#{NavigationBean.searchContext == null}">
    <f:facet name="header">
     <h:outputText id="fo_col-txt" value="#{msg.actions}"/>

</f:facet> 
<a:actionLink id="fo_col-act" value="#{r.name}" href="#{r.url}"
target="new" image="#{r.fileType16}" showLink="false" styleClass="inlineAction" />
<%-- actions are configured in web-client-config-actions.xml --%>
<r:actions id="fo_col-acts" value="approve_doc_actions_browse" context="#{r}"
showLink="false" styleClass="inlineAction" />

</a:column>



 

  1. Use below tag to display the action into view details page of the content

    <%-- Document Actions --%>

    <a:panel label="#{msg.actions}" id="actions-panel" border="white" bgcolor="white" titleBorder="lbgrey" expandedTitleBorder="dotted" titleBgcolor="white" style="text-align:center" progressive="true" expanded='#{DialogManager.bean.panels["actions-panel"]}'
    expandedActionListener="#{DialogManager.bean.expandPanel}">

        <r:actions id="actions_doc" value="fo_doc_details_actions"             context="#{DialogManager.bean.document}"
        verticalSpacing="3" style="white-space:nowrap" />

    </a:panel>

    1. Define the label text to be displayed in JSP in webclient.properties
        approve_document=Approved

  Now you have created your new customized action link.

Similarly you can create more actions and display it in one action group.

No comments: