cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Button in Alfresco Repository

nm_santos
Champ in-the-making
Champ in-the-making
Good afternoon,

I'm looking to add a new button in the Alfresco Repository, more specifically, an action.

What I want to is, when a user selects my action in a respective file, it sends the file to a remote server along with the ID of the file's creator/uploader.

Is this doable?

Sorry for this newbie question, but I'm still getting familiar to alfresco.

I'm not sure if I should start with http://wiki.alfresco.com/wiki/Custom_Actions.

Tips?

I'm using Alfresco 3.4

Regards,
Nuno.
9 REPLIES 9

jpotts
World-Class Innovator
World-Class Innovator
Hi, Nuno.

You are saying "Alfresco Repository" but you are talking about UI actions. There are two out-of-the-box user interfaces. One is called "Alfresco Explorer" and the other is called "Alfresco Share". Both support doing what you are trying to do. Usually, "Repository" is a back-end concept that has no user interface.

If you are adding your UI action to Share, take a look at this tutorial. If you are adding your UI action to Explorer you might look at Chapter 5 of the Alfresco Developer Guide. The accompanying code for the book lives here.

The wiki page you pointed to is about custom actions that make changes to a node. In your case, you aren't making a change to a node, you are gathering some information from the node and then redirecting the user to a specific link. So as you look at the wiki and the docs, you definitely want a "UI action" instead of a "rule action".

Hope that helps,

Jeff

nm_santos
Champ in-the-making
Champ in-the-making
Hi, Nuno.

You are saying "Alfresco Repository" but you are talking about UI actions. There are two out-of-the-box user interfaces. One is called "Alfresco Explorer" and the other is called "Alfresco Share". Both support doing what you are trying to do. Usually, "Repository" is a back-end concept that has no user interface.

If you are adding your UI action to Share, take a look at this tutorial. If you are adding your UI action to Explorer you might look at Chapter 5 of the Alfresco Developer Guide. The accompanying code for the book lives here.

The wiki page you pointed to is about custom actions that make changes to a node. In your case, you aren't making a change to a node, you are gathering some information from the node and then redirecting the user to a specific link. So as you look at the wiki and the docs, you definitely want a "UI action" instead of a "rule action".

Hope that helps,

Jeff

Thanks for the reply, Jeff.

What I meant by repository is the repository section that appears on the UI Smiley Happy

As I won't be creating collaboration sites, and only use that section.

I'll try the guides.

Regards,

Nuno.

nm_santos
Champ in-the-making
Champ in-the-making
Hi,

After doing the tutorial, I'm starting to code my own custom action.

However, I'm still missing some things:

1. What should I do in the addParameterDefinitions? What should I insert in the last parameter? Where is the label?

@Override
   protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
      paramList.add(
            new ParameterDefinitionImpl(               // Create a new parameter definition to add to the list
                  "file"                          // The name used to identify the parameter
                  DataTypeDefinition.CONTENT,             // The parameter value type
                  true,                                  // Indicates whether the parameter is mandatory
                  ?????);   // The parameters display label

   }

All I need is to send the current selected file to a remote web service.

Regards,
Nuno.

jpotts
World-Class Innovator
World-Class Innovator
There is a helper method called getParamDisplayLabel that will return the localized string to be used as the label. So in your case, you'd use getParamDisplayLabel("file")

One observation: If your intent is to have an action that will send the file to someone when the action is invoked, and the action will be invoked from the UI while the user is looking at the document that is to be sent, you do not need to pass a "file" parameter to refer to the file to send. The action will automatically be handed the "actionedUponNodeRef" which will point to the node the action is being invoked on. You can then use the ContentService to get the bytestream and then you can construct the attachment from that.

Jeff

nm_santos
Champ in-the-making
Champ in-the-making
Hi Jeff,

Thanks! Smiley Happy

I got over that part.

As for the structure of o my project, I won't be deploying it to a collaboration site, I want to deploy it directly to alfresco.

I've already read http://wiki.alfresco.com/wiki/AMP_Files and http://wiki.alfresco.com/wiki/Developing_an_Alfresco_Module.

It seems that what I want, is not the same as described in the guide that you gave me, because there he deploys a site separately. Am I correct?

For example, I should insert the context.xml file directly in ALFRESCO_HOME\tomcat\shared\classes\alfresco\extension ?

I'm using Community Edition 3.4

Regards,
Nuno.

jpotts
World-Class Innovator
World-Class Innovator
Your action executer should be in a JAR file. That JAR file will live under the alfresco WAR in WEB-INF/lib. If your UI action is going to appear in the Alfresco Share user interface, your UI action related configuration files will be deployed to the share WAR. The recommended approach would be for you to create an AMP file for the alfresco WAR and an AMP file for the share WAR, each with their appropriate artifacts.

The tutorial I referred you to does not use AMPs. It uses the approach of putting the files into a zip (one for the alfresco WAR and one for the share WAR) structured so that when they are unzipped on top of the exploded WARs, the files go where they are supposed to go.

The end result is the same–files are placed into the alfresco and share WARs. The difference is that AMPs are a more reliable way to deploy the files into the WAR because Alfresco's MMT tool is responsible for putting the files where they go. And, at some point, AMPs will support more advanced features. So we'd like to see everyone going the AMP route if possible.

Jeff

nm_santos
Champ in-the-making
Champ in-the-making
Hi Jeff,

I've decided to change to Alfresco 4.0 and successfully deployed my AMP to alfresco.war

Now as for the buttons to appear, and associate the buttons with the actions, I'm having trouble.

I've edited share-config-custom.xml and added this:

<!– Actions –>
    <config evaluator="string-compare" condition="DocLibActions">
        <actions>
         <action id="file-transfer" type="javascript" label="actions.document.file-transfer">
                <param name="function">onActionSimpleRepoAction</param>
                <param name="action">file-transfer</param>
            </action>
      </action>
   </config>

In your guide, you have a scModel.properties, but what do I do now? I don't have that file.

Regards,
Nuno.

jpotts
World-Class Innovator
World-Class Innovator
I see you've declared your action (although, I note that your closing "</action>" tag should be "</actions>") but I do not see any action groups. Here are my action groups from the tutorial:
<actionGroups>
    <actionGroup id="document-browse">
        <action index="500" id="someco-web-site" />
        <action index="510" id="someco-web-enable" />
        <action index="520" id="someco-web-disable" />
    </actionGroup>
    <actionGroup id="document-details">
        <action index="500" id="someco-web-site" />
        <action index="510" id="someco-web-enable" />
        <action index="520" id="someco-web-disable" />
    </actionGroup>
</actionGroups>
This would be added immediately following the closing "</actions>" tag. In the example above, I am adding three new actions to both the document list and to the document details page.

Jeff

nm_santos
Champ in-the-making
Champ in-the-making
Hi Jeff,

I've successfully installed my new AMP, and everything works fine!

Thanks for your help.

Regards,
Nuno.