cancel
Showing results for 
Search instead for 
Did you mean: 

Custom action - Redirection (web page)

jlocke
Champ in-the-making
Champ in-the-making
Hello,

I have created a custom action (available on document details page) thanks to Jeff Potts' tutorial (http://ecmarchitect.com/images/articles/alfresco-actions/actions-article-2ed.pdf) which executes a Java method (executeImpl)
This function is used to delete a workflow instance (the first one) associated with the current document. About that job, everything is ok.
But, once it is done, I want this action to redirect the user who clicked the button to the next document (details page) associated with another workflow. Just like the "Delete document" action which deletes the current document and redirects to the parent folder.

Is that possible ?

Thanks in advance, and sorry for my english.

Alfresco Community 4.0.d (Ubuntu 10.04)
2 REPLIES 2

vamirr
Champ on-the-rise
Champ on-the-rise
Jlocke,

I did something similar.    My action is available on folders only,  and it creates a zip file of the folder contents.   I wanted the action to perform a redirect in Share to download the generated zip file.


Take a look at my code.  Look for my window.open call.   The file below is my zip-actions.js file located in webapps/share/components/documentlibrary


  (function() {
    YAHOO.Bubbling.fire("registerAction",
    {
        actionName: "onActionZipExport",
        fn: function vamirr_onActionZipExport(file) {
                try{
                nodeId = file.nodeRef.replace("workspace://SpacesStore/","");
                console.log(nodeId);

                this.widgets.popupMessage = Alfresco.util.PopupManager.displayMessage(
                {       text: Alfresco.util.message("message.ZipExport.progress", file.displayName),
                        spanClass: "wait",
                        displayTime: 1000,
                        effect: null,
                        modal:true
                });
           //return;
                }catch(err){alert(err);}
            this.modules.actions.genericAction(
            {
                success:
                {
                    message: this.msg("message.ZipExport.success", file.displayName),
                    callback : {
                        scope: this,
                        fn: function(object){
                          this.widgets.popupMessage.destroy();
                          var result = eval('(' + object.serverResponse.responseText + ')');
                          var newLocation = "/share/proxy/alfresco/api/node/content/workspace/SpacesStore/" + result.download;
                          window.open(window.location.protocol + "//" + window.location.hostname +  newLocation, "_new");
                               }
                     },
                    event:  {   name: "metadataRefresh"  }

                },
                failure:
                {
                    message: this.msg("message.ZipExport.failure", file.displayName),
                    callback : {
                        scope: this,
                        fn: function(object){   this.widgets.popupMessage.destroy();}
                     },
                    event:  {   name: "metadataRefresh"  }

                },
                webscript:
                {
                    name: "vamirr/zipexport/{nodeRef}.json",
                    stem: Alfresco.constants.PROXY_URI,
                    method: Alfresco.util.Ajax.GET,
                    params:
                    {
                        nodeRef: nodeId
                    }
                },
                config:
                {
                }

            });
        }
    });
})();


(function() {
    YAHOO.Bubbling.fire("registerAction",
    {
        actionName: "onActionZipImport",
        fn: function vamirr_onActionZipImport(file) {
       this.widgets.popupMessage = Alfresco.util.PopupManager.displayMessage(
         {
                     text: Alfresco.util.message("message.ZipImport.progress", file.displayName),
                     spanClass: "wait",
                     displayTime: 1000,
                     effect: null,
           modal: true
                     });
      //return;
            this.modules.actions.genericAction(
            {
              success:
                {
                    message: this.msg("message.ZipImport.success", file.displayName),
                    callback : {
                        scope: this,
                        fn: function(object){
                          this.widgets.popupMessage.destroy();
                               }
                     },
                    event:  {   name: "metadataRefresh"  }
                },
                failure:
                {
                    message: this.msg("message.ZipImport.failure", file.displayName),
                    callback : {
                        scope: this,
                        fn: function(object){   this.widgets.popupMessage.destroy();}
                     },
                    event:  {   name: "metadataRefresh"  }
                },
                webscript:
                {
                    name: "vamirr/zipimport?nodeRef={nodeRef}",
                    method: Alfresco.util.Ajax.GET,
          stem: Alfresco.constants.PROXY_URI,
                    params:
                    {
                        nodeRef: file.nodeRef
                    }
                },
                config:
                {
                }

            });
        }
    });
})();



jlocke
Champ in-the-making
Champ in-the-making
Thank you very much for you help Vamirr !  Smiley Very Happy

I'm now using a javascript action and a web script like you did.