cancel
Showing results for 
Search instead for 
Did you mean: 

Custom action using server side javascript

robert_begin
Champ on-the-rise
Champ on-the-rise
I would like to add a new action on Share's document-browse page (Alfresco 4.1) which executes a server side-javascript residing in repo at companyhome\Data Dictionary\scripts\mypublish.js

The javascript transforms the doc to PDF and moves it to a static folder.  (No client-side javascript is required)
<!–break–>
The javascript works fine when tied to a folder rule, but I want the users to choose my "Publish to PDF" icon when a particular document needs to be published (not all docs in particular folder need to be published)

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

<!– Custom DocLibActions config section –>
  <config evaluator="string-compare" condition="DocLibActions">
    <actions>
      <action id="mypublish" icon="publish" type="javascript" label="actions.mycompany.mypublish">
        <param name="function">onActionSimpleRepoAction</param>
        <param name="action">mypublish</param>
      </action>
    </actions>
    <!–
       Action Group definitions
    –>
    <actionGroups>
      <actionGroup id="document-browse">
        <action index="400" id="mypublish" />
      </actionGroup>   
    </actionGroups>
  </config>

So the icon appears on the document-browse Share page, but clicking the icon does not launch the s-s javascript.

BUT how do I configure this through Spring ???

Noted from JPotts:

A quick side-note before moving on to the front-end: The action executer examples shown in Part 1
were both implemented in Java. However, action executers can also be implemented using server-side
JavaScript. The steps are the same: write the logic, then configure it through Spring.

I know I can accomplish this with the "document-execute-script" action, but the user has the extra step of selecting the proper javascript.
10 REPLIES 10

dhaval_patel_10
Champ in-the-making
Champ in-the-making
Hi I read the issue and your post, its usefull.

I think i have the same thing
i have a share action which calls a webscript and the webscript calls a bean configuration action which calls a repository javascript file. i wanted to pass the parameters to that js. but i want it like a dynamic part so i want that static values to be passed from xml which i can be able to receive at repository javascript file.

there can be two ways to pass parameters from webscript where i call my action and receive it at javascript and other way it by passing it from xml.

i choose to be pass it from xml.
for the first way i tried to pass it to parameters from webscript js but not able to receive it at javascript with any defaul variables like args, etc..
and i am trying for passing with xml but i think the script class is not giving me that property to be passed

anyone have any idea about static values pass from xml to javascript..  ?