cancel
Showing results for 
Search instead for 
Did you mean: 

Show dialog in a Share action calling a JavaScript WebScript

douglascrp
World-Class Innovator
World-Class Innovator
I'm trying to config an action, which calls a javascript function, like the example on this site
http://ecmstuff.blogspot.com.br/2012/04/adding-document-library-actions-in.html

The action is:

      <action id="mycompany.doclib.action.sendAsEmail"
              icon="email"
              type="javascript"
              label="actions.mycompany.sendAsEmail">
         <param name="function">onActionSendAsEmail</param>
         <param name="successMessage">message.sendAsEmail.success</param>
         <param name="failureMessage">message.sendAsEmail.failure</param>
         <evaluator negate="true">mycompany.evaluator.doclib.action.isEmailed
         </evaluator>
      </action>

and the javascript funcion is defined like this


(function() {
    YAHOO.Bubbling.fire("registerAction",
    {
        actionName: "onActionSendAsEmail",
        fn: function mycompany_onActionSendEmail(file) {
            this.modules.actions.genericAction(
            {
                success:
                {
                    message: this.msg("message.sendAsEmail.success", file.displayName, Alfresco.constants.USERNAME)
                },
                failure:
                {
                    message: this.msg("message.sendAsEmail.failure", file.displayName, Alfresco.constants.USERNAME)
                },
                webscript:
                {
                    name: "mycompany/sendDocInEmail?nodeRef={nodeRef}&userName={userName}",
                    stem: Alfresco.constants.PROXY_URI,
                    method: Alfresco.util.Ajax.GET,
                    params:
                    {
                        nodeRef: file.nodeRef,
                        userName: Alfresco.constants.USERNAME
                    }
                },
                config:
                {
                }

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

Evething work this way.

In the same site, the author shows how to call a form dialog, where user can type some text, which are passed to the action.


    <action id="mycompany.doclib.action.sendAsEmailWithForm"
            icon="email"
            type="javascript"
            label="actions.mycompany.sendAsEmailWithForm">
        <param name="function">onActionFormDialog</param>
        <param name="itemKind">action</param>
        <param name="itemId">send-as-email</param>
        <param name="mode">create</param>
        <param name="destination">{node.nodeRef}</param>
        <param name="successMessage">message.send-as-email.success</param>
        <param name="failureMessage">message.send-as-email.failure</param>
        <evaluator negate="true">
mycompany.evaluator.doclib.action.isEmailed</evaluator>
    </action>

I'm trying to do the same, but the difference between my webscript and the site's webscript is that my webscript is javascript based, and the site's webscript is java based.
The author have configured a bean, which is used in the itemId parameter


<bean id="send-as-email" class="com.mycompany.cms.action.SendAsEmailActionExecuter" parent="action-executer">
        <property name="alfrescoRepoHelper">
            <ref bean="alfrescoRepoHelper"/>
        </property>
        <property name="nodeService">
            <ref bean="NodeService"/>
        </property>
    </bean>

How to make the action to show the form dialog, but calling my javascript webscript instead of java webscript (bean)?

Sorry for the English… I'm typing in a hurry

Thanks in advance
3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator
Hello,

the authors class is NOT a Java-based web script, but simply a Java-based action - there is a difference between these two. Note that the initial Java-class is indeed a web script, but not the last example you referred to with the executor bean. An action can be called by the onActionFormDialog method - a webscript can't. Either you change your web script to a proper action or you stick to the initial action and change it to show a form which submits to your web script (note: every form can be configured to submit to a web script instead of the form service via a submission URL parameter).

Regards
Axel

romvdn58
Champ in-the-making
Champ in-the-making
Hello,
I'm trying to do the same thing than douglascrp but I'm new on Alfresco and Yahoo Toolkit… So I need help to follow your instructions in order to change the action to show a form.

If I understand, I take the same function "YAHOO.Bubbling.fire" and construct my dialog call in


n: function mycompany_onActionSendEmail(file) { … }

??

Another question is : what should I use to display a dialog (Alfresco.modules.SimpleDialog?). My need is to invite the user to select an item in a dropdown list on the dialog form and to call a javascript webscript with this dropdown list value as parameter when submit.

Then do I call  "this.modules.actions.genericAction(…)" on the submit dialog function ?

Thanks for your help

douglascrp
World-Class Innovator
World-Class Innovator
You are right.

Thanks