03-22-2010 03:50 AM
05-16-2010 05:16 PM
<script type="text/javascript" src="/share/components/documentlibrary/backup-action.js"></script>05-16-2010 05:26 PM
<#include "../component.head.inc">
<!– Document List –>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/components/documentlibrary/documentlist.css" />
<@script type="text/javascript" src="${page.url.context}/components/documentlibrary/documentlist.js"></@script>
<!– Backup Action –>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/components/documentlibrary/backup-action.css" />
<@script type="text/javascript" src="${page.url.context}/components/documentlibrary/backup-action.js"></@script>
Web Script: org/alfresco/slingshot/documentlibrary/action/backup.post
Generated from /alfresco/service/script/org/alfresco/slingshot/documentlibrary/action/backup.post on May 17, 2010 1:23:30 AM
Script Properties
Id:   org/alfresco/slingshot/documentlibrary/action/backup.post
Short Name:   backup
Description:   Document List Action - Backup document(s)
Authentication:   user
Transaction:   required
Method:   POST
URL Template:   /slingshot/doclib/action/backup/site/{site}/{container}
Format Style:   argument
Default Format:   json
Negotiated Formats:   [undefined]
Implementation:   class org.alfresco.web.scripts.DeclarativeWebScript
Extensions:   [undefined]
Store: workspace://SpacesStore/app:company_home/app:dictionary/cm:extensionwebscripts
File: org/alfresco/slingshot/documentlibrary/action/backup.post.json.js
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js">
/**
 * Backup multiple files action
 * @method POST
 */
/**
 * Entrypoint required by action.lib.js
 *
 * @method runAction
 * @param p_params {object} Object literal containing files array
 * @return {object|null} object representation of action results
 */
function runAction(p_params)
{
   var results = [];
   var files = p_params.files;
   var file, fileNode, result, nodeRef;
   // Find destination node
   var destNode = p_params.rootNode.childByNamePath("/Backup");
   if (destNode == null)
   {
      destNode = p_params.rootNode.createFolder("Backup");
   }
   // Must have destNode by this point
   if (destNode == null)
   {
      status.setCode(status.STATUS_NOT_FOUND, "Could not find or create /Backup folder.");
      return;
   }
   // Must have array of files
   if (!files || files.length == 0)
   {
      status.setCode(status.STATUS_BAD_REQUEST, "No files.");
      return;
   }
   for (file in files)
   {
      nodeRef = files[file];
      result =
      {
         nodeRef: nodeRef,
         action: "backupFile",
         success: false
      }
      try
      {
         fileNode = search.findNode(nodeRef);
         if (fileNode === null)
         {
            result.id = file;
            result.nodeRef = nodeRef;
            result.success = false;
         }
         else
         {
            result.id = fileNode.name;
            result.type = fileNode.isContainer ? "folder" : "document";
            // copy the node to the backup folder
            result.nodeRef = fileNode.copy(destNode);
            result.success = (result.nodeRef !== null);
         }
      }
      catch (e)
      {
         result.id = file;
         result.nodeRef = nodeRef;
         result.success = false;
      }
      results.push(result);
   }
   return results;
}
/* Bootstrap action script */
main();
File: org/alfresco/slingshot/documentlibrary/action/backup.post.json.ftl
<#import "action.lib.ftl" as actionLib />
<@actionLib.resultsJSON results=results />
File: org/alfresco/slingshot/documentlibrary/action/backup.post.desc.xml
<webscript>
  <shortname>backup</shortname>
  <description>Document List Action - Backup document(s)</description>
  <url>/slingshot/doclib/action/backup/site/{site}/{container}</url>
  <format default="json">argument</format>
  <authentication>user</authentication>
  <transaction>required</transaction>
</webscript>
Store: workspace://SpacesStore/app:company_home/app:dictionary/cm:webscripts
[No implementation files]
Store: classpath:alfresco/templates/webscripts
[No implementation files]
Store: classpath:alfresco/webscripts
[No implementation files]
 
					
				
		
05-17-2010 04:27 AM
06-01-2010 06:29 AM
To ensure both these files are served to the web browser, you need to add two lines (and a suitable comment is recommended) to the documentlist.get.head.html presentation template. Question: Is the document we edit documentlist.get.html.ftl or documentlist.get.head.ftl?
 
					
				
		
06-01-2010 07:43 AM
http://wiki.alfresco.com/wiki/Custom_Document_Library_Action
I am also unable to get it working. A confusion on the tutorial is this:To ensure both these files are served to the web browser, you need to add two lines (and a suitable comment is recommended) to the documentlist.get.head.html presentation template. Question: Is the document we edit documentlist.get.html.ftl or documentlist.get.head.ftl?
First there is no file like this: "documentlist.get.head.html".
06-01-2010 09:52 AM
If you can't get it working I'll be able to help (I have a working custom action), but it's been too long ago for me to remember everything I did back then…
<documentList>
   <actionSets>
      <actionSet id="empty"></actionSet>
      <actionSet id="document">
         <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download" />
         <action type="action-link" id="onActionDetails" permission="edit" label="actions.document.edit-metadata" />
         <action type="action-link" id="onActionUploadNewVersion" permission="edit" label="actions.document.upload-new-version" />
         <action type="action-link" id="onActionEditOnline" permission="edit,online-edit" label="actions.document.edit-online" />
         <action type="action-link" id="onActionEditOffline" permission="edit" label="actions.document.edit-offline" />
         <action type="action-link" id="onActionCopyTo" label="actions.document.copy-to" />
         <action type="action-link" id="onActionMoveTo" permission="delete" label="actions.document.move-to" />
         <action type="action-link" id="onActionDelete" permission="delete" label="actions.document.delete" />
         <action type="action-link" id="onActionAssignWorkflow" label="actions.document.assign-workflow" />
         <action type="action-link" id="onActionManagePermissions" permission="permissions" label="actions.document.manage-permissions" />
         <action type="action-link" id="onActionManageAspects" permission="edit" label="actions.document.manage-aspects" />
   <action id="onActionBackup" type="action-link" permission="" label="actions.document.backup" />
      </actionSet>
      <actionSet id="locked">
         <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download" />
      </actionSet>
      <actionSet id="lockOwner">
         <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download-original" />
      </actionSet>
      <actionSet id="workingCopyOwner">
         <action type="action-link" id="onActionUploadNewVersion" label="actions.document.upload-new-version" />
         <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download-again" />
         <action type="action-link" id="onActionCancelEditing" permission="edit" label="actions.document.cancel-editing" />
      </actionSet>
      <actionSet id="folder">
         <action type="simple-link" id="onActionMetadata" href="{folderDetailsUrl}" label="actions.folder.view-metadata" />
         <action type="action-link" id="onActionDetails" permission="edit" label="actions.folder.edit-metadata" />
         <action type="action-link" id="onActionCopyTo" label="actions.folder.copy-to" />
         <action type="action-link" id="onActionMoveTo" permission="delete" label="actions.folder.move-to" />
         <action type="action-link" id="onActionDelete" permission="delete" label="actions.folder.delete" />
         <action type="action-link" id="onActionManagePermissions" permission="permissions" label="actions.folder.manage-permissions" />
         <action type="action-link" id="onActionManageAspects" permission="edit" label="actions.folder.manage-aspects" />
      </actionSet>
      <actionSet id="link">
         <action type="action-link" id="onActionDelete" permission="delete" label="actions.link.delete" />
      </actionSet>
   </actionSets>
</documentList>/**
 * DocumentList "Backup" action
 * 
 * @namespace Alfresco
 * @class Alfresco.DocumentList
 */
(function()
{
   /**
    * Backup single document.
    *
    * @method onActionBackup
    * @param row {object} DataTable row representing file to be actioned
    */
   Alfresco.doclib.Actions.prototype.onActionBackup = function DL_onActionBackup(file)
   {
   alert("TEST")
   this.modules.actions.genericAction(
      {
         success:
         {
            message: this._msg("message.backup.success", file.displayName)
         },
         failure:
         {
            message: this._msg("message.backup.failure", file.displayName)
         },
         webscript:
         {
            name: "/slingshot/doclib/action/backup/site/{site}/{container}",
            method: Alfresco.util.Ajax.POST
         },
         params:
         {
            site: this.options.siteId,
            container: this.options.containerId
         },
         config:
         {
            requestContentType: Alfresco.util.Ajax.JSON,
            dataObj:
            {
               nodeRefs: [file.nodeRef]
            }
         }
      });
   };
})();<#include "../component.head.inc">
<!– Document List –>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/components/documentlibrary/documentlist.css" />
<@script type="text/javascript" src="${page.url.context}/components/documentlibrary/documentlist.js"></@script>
<!– Backup Action –>
<link rel="stylesheet" type="text/css" href="${page.url.context}/components/documentlibrary/backup-action.css" />
<script type="text/javascript" src="${page.url.context}/components/documentlibrary/backup-action.js"></script>
06-01-2010 10:28 AM
…
<!– Document List –>
   <script type="text/javascript" src="/share/components/documentlibrary/documentlist-min.js"></script>
<!– Backup Action –>
<link rel="stylesheet" type="text/css" href="/share/components/documentlibrary/backup-action.css" />
<script type="text/javascript" src="/share/components/documentlibrary/backup-action.js"></script>
   <style type="text/css" media="screen">
      @import "/share/components/documentlibrary/documentlist.css";
   </style>
…
<div class="onActionManageAspects"><a rel="edit" href="" class="action-link" title="Manage Aspects"><span>Manage Aspects</span></a></div>
<div class="onActionBackup"><a rel="" href="" class="action-link" title="Backup"><span>Backup</span></a></div>
…
 
					
				
		
06-01-2010 10:42 AM
I have the following file:
/var/lib/tomcat6/shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/actions-common.get.head.ftl, which has same contents as the original (in WEB-INF) with the following appended:<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/documentlibrary/download-pdf-action.css" />
<script type="text/javascript" src="${page.url.context}/res/components/documentlibrary/download-pdf-action.js"></script>
These refer to the client side files that are needed to invoke the action.
06-01-2010 01:40 PM
 
					
				
		
06-01-2010 04:05 PM
What can be the possible reason of the fact that clicking on "Backup" action does not trigger the Javascript? Any idea?
javascript:alert(Alfresco.DocumentList.prototype.onActionBackup); 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.