cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Action and Contet type

giafar
Champ in-the-making
Champ in-the-making
Hi all,
I'm developing a Custom Action but i want it can be available for just some content type.
How can i handle this ?

Thanks in advance.
1 REPLY 1

zaizi
Champ in-the-making
Champ in-the-making
Download the source code for the Blog integration from Alfresco svn. It is quite useful to see how the Web client is customised for specific content types.

This is the custom action definition in web-client-custom.xml. Note the evaluator parameter.

         <action id="addBlogDetails">      
            <permissions>
               <permission allow="true">Write</permission>
            </permissions>
            <evaluator>org.alfresco.module.blogIntegration.ui.AddBlogDetailsEvaluator</evaluator>
            <label>Add Blog Details</label>
            <image>/images/icons/edit_icon.gif</image>
          <action-listener>#{org_alfresco_module_blogIntegration_BlogDetailsActionListener.executeScript}</action-listener>
          <params>
              <param name="id">#{actionContext.id}</param>
               <param name="action">add</param>
            </params>
         </action>

The code for the evaluator below checks if the current node has a specific aspect. You'll just need to check that the node is your content type.

public class AddBlogDetailsEvaluator extends BaseActionEvaluator implements BlogIntegrationModel
{
    /**
     * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
     */
    public boolean evaluate(Node node)
    {
        boolean result = false;
        if (node.hasAspect(ASPECT_BLOG_DETAILS) == false)
        {
            result = true;
        }
        return result;
    }
}

Hope that still helps.