cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Action To Trigger Download of Node's Content

vamirr
Champ on-the-rise
Champ on-the-rise
I'm trying to develop a custom action in Share that will trigger the download of content from a node in another location.

The idea is that upon clicking the custom action on the folder in Share, a java-backed webscript generates a new node in the repository in some other directory and populates its content accordingly.  After creation, I need to trigger a download of the content.


At this point, my java-backed webscript operates as expected. It takes an argument of the folder nodeRef and the output freemarker template contains an html redirect to download the newly created content. 

The action is visible under actions in Share's document library for folders. Clicking it creates the new node.   My question is then how can I trigger the download within the Share action code (modules.actions.genericAction).
2 REPLIES 2

vamirr
Champ on-the-rise
Champ on-the-rise
The solution is to provide the genericAction constructor a callback function in the case of a success. 

That callback function is is given a result object that contains the text result from the webscript.  

I changed the webscript to output just the URL of the node to be downloaded instead of an HTML page with an HTML redirect in it.  

Now, I just pull the result in the success callback function and do the redirect in javascript.


Alfresco.DocumentList.prototype.onActionZipExport = function DL_onActionZipExport(file)
  {
     this.modules.actions.genericAction(
      {
         success:
         {
            message: this.msg("message.zipexport.success", file.displayName),
            event:  {   name: "metadataRefresh"  },
            callback : {        fn: function(object){   window.location = object.serverResponse.responseText;

….

The result looks like this:   http://www.youtube.com/watch?v=MA67QHYqBSg

prker63
Champ on-the-rise
Champ on-the-rise
Hi Vamirr,

Could you share your solution with us? I'm also looking for a solution to generate a zip for the contents of a folder and store that zipfile alongside the folder.
Thanx in advance