cancel
Showing results for 
Search instead for 
Did you mean: 

Share 3.2 Custom Example - Not working

ahamed_rasmi
Champ in-the-making
Champ in-the-making
Hi,

Example given in following link not working for me.

http://wiki.alfresco.com/wiki/Custom_Document_Library_Action

I am in Alfresco 3.2 RC share site..

The Script backup-action-min.js is found when i view source in IE7..

The relative paths are correct..

Webscripts also responds to URL POST..

Help is sought.
28 REPLIES 28

mycroes
Champ in-the-making
Champ in-the-making
Hi,

I used the example to develop a custom action, although I'm not sure I've followed it exactly I did get it working. If you could use a browser with proper debugging support (Safari, Google Chrome or Firefox with Firebug), you can tell where it's going wrong.

If you check the following and report back I'm sure I can give a more detailed answer:
  • Is the client side JavaScript file loaded?

  • Is a request being made when the action is clicked?

  • Are the correct parameters sent along with the request?

  • What is the response of the request being made?
If you use Firefox with Firebug you'll see the requests in the Firebug console and can see exactly what's being posted and returned.
Regards,

Michael

dark_rider
Champ on-the-rise
Champ on-the-rise
I have the same problem, I applied the example step by step but the custom action link does not do anything?
Any idea?

mycroes
Champ in-the-making
Champ in-the-making
I have the same problem, I applied the example step by step but the custom action link does not do anything?
Any idea?

Read the post before yours and answer the questions, might solve a lot!
Regards,

Michael

dark_rider
Champ on-the-rise
Champ on-the-rise
* Is the client side JavaScript file loaded?
    * Is a request being made when the action is clicked?
    * Are the correct parameters sent along with the request?
    * What is the response of the request being made?

1-yes client side js is loaded i see when i display the page source code

<script type="text/javascript" src="/share/components/documentlibrary/backup-action.js"></script>


2-there is no response(client ore server) being made when I clicked

3-here is my documentlist.get.config.xml   file


      <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="onActionBackup" permission="edit" label="actions.document.backup" />
      </actionSet>

4. here is my backup-action.js

/**
* 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.DocumentList.prototype.onActionBackup = function DL_onActionBackup(row)
   {
      var file = this.widgets.dataTable.getRecord(row).getData();

      this.modules.actions.genericAction(
      {
    
         success:
         {
            message: this._msg("message.backup.success", file.displayName)
         },
         failure:
         {
            message: this._msg("message.backup.failure", file.displayName)
         },
         webscript:
         {
            name: "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]
            }
         }
      });
   };
})();

mycroes
Champ in-the-making
Champ in-the-making
* Is the client side JavaScript file loaded?


1-yes client side js is loaded i see when i display the page source code

<script type="text/javascript" src="/share/components/documentlibrary/backup-action.js"></script>

I'm sorry but you failed to correctly answer the question… I asked if it's being loaded, not if it's being referenced. If you use a modern browser you can check the resources section whether the file was loaded, otherwise you can paste the url into your address bar and see if you can reach the file (which doesn't assure it's being loaded, but at least means it's loadable). If you're not able to check any of these, add an alert statement to the script, if it fires then it's being loaded.

If no request is triggered, then I'd assume something is wrong in the client side script, so also check for javascript errors that get triggered when you try to invoke the action.
Regards,

Michael

dark_rider
Champ on-the-rise
Champ on-the-rise
It loads, I see alerts and I use firefox, when i clicked the backup-action.js  the source appears.

Sould I reinstall the alfresco and apply the steps again?
Thanks your help

mycroes
Champ in-the-making
Champ in-the-making
No, I'm guessing the guide is bugged, not your install. I followed the install myself and also ran into some issues, however it's been a while ago and I don't remember the exact issues I ran into… One thing that comes to mind is that the server side javascript file should be named backup-action.json.js. If you use firebug you can see the server response to the request being made by the client, which also contains errors if there are any. If you could look those up that might provide more useful information.
Regards,

Michael

mikeh
Star Contributor
Star Contributor
It's likely because you're still using the pre-v3.2 "getRecord()" style when the wiki article states not to for v3.2 onwards. http://wiki.alfresco.com/wiki/Custom_Document_Library_Action#Action_JavaScript

Check the "Note for V3.2" section.

Thanks,
Mike

P.S. If you find a wiki article is "bugged" please find the time to correct it - that's what a wiki is all about!  Smiley Happy

dark_rider
Champ on-the-rise
Champ on-the-rise
It's likely because you're still using the pre-v3.2 "getRecord()" style when the wiki article states not to for v3.2 onwards. http://wiki.alfresco.com/wiki/Custom_Document_Library_Action#Action_JavaScript

Check the "Note for V3.2" section.

Thanks,
Mike

P.S. If you find a wiki article is "bugged" please find the time to correct it - that's what a wiki is all about!  Smiley Happy

thanks, but it doesnt work, I tried many others,  I chanced before the V3.2 codes like following…
My backup-action.cs file is in    C:\Alfresco\tomcat\webapps\share\components\documentlibrary
Should I copy the backup-action.js file anywhere else?
I have to do this otherwise i am gonna be crazy  Smiley Indifferent

/**
* DocumentList "Backup" action
*
* @namespace Alfresco
* @class Alfresco.DocumentList
*/
(function()
{
   /**
    * Backup single document.
    *
    * @method onActionBackup
    * @param row {object} DataTable row representing file to be actioned
    */
   alert("backup-action.js imported");
   
   Alfresco.doclib.Actions.prototype.onActionBackup = function DL_onActionBackup(file)
   {
      this.modules.actions.genericAction(
      {
    
         success:
         {
            message: this.msg("message.backup.success", file.displayName)
         },
         failure:
         {
            message: this.msg("message.backup.failure", file.displayName)
         },
         webscript:
         {
            name: "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]
            }
         }
      });
   };
})();