cancel
Showing results for 
Search instead for 
Did you mean: 

Redirection after onActionFormDialog

jmoyano
Champ in-the-making
Champ in-the-making
Hi, i am trying to create an action that when clicked, it displays a popup to gather a couple of parameters from the user, and then when the user clicks the "OK" button he get redirected to another page (this page needs the two parameters mentioned before to be passed in the url). I can't find how to make this redirection…
this is what I've done already:

share-config-custom.xml



<config evaluator="string-compare" condition="DocLibActions">
      <actions>
         <action id="com.mycompany.customaction"
            icon="actionIcon" type="javascript" label="customaction.label.title">
            <param name="function">onActionFormDialog</param>
            <param name="itemKind">action</param>
            <param name="itemId">customAction</param>
            <param name="mode">create</param>
            <param name="destination">{node.nodeRef}</param>
            <param name="successMessage">customaction.action.success</param>
            <param name="failureMessage">customaction.action.failure</param>
            <evaluator>com.mycompany.customEvaluator</evaluator>
         </action>
      </actions>
      <actionGroups>
         <actionGroup id="document-details">
            <action index="400" id="com.mycompany.customaction" />
         </actionGroup>
      </actionGroups>
   </config>

   <config evaluator="string-compare" condition="customAction">
      <forms>
         <form>
            <field-visibility>
               <show id="param1" />
               <show id="param2" />
            </field-visibility>
            <appearance>
               <field id="param1" label-id="customaction.field.param1"/>
               <field id="param2" label-id="customaction.field.param2"/>
            </appearance>
         </form>
      </forms>
   </config>



The action is triggered and it displays the success message. What do i have to do to redirect after the action?
Thanks!
4 REPLIES 4

rjohnson
Star Contributor
Star Contributor
You will need some custom javascript called when someone clicks OK on your dialog to do window.location type redirect. You have available the "success" and "failure" parameter in the Action which allows you to define a callback that will be executed and that can do the redirect.

jmoyano
Champ in-the-making
Champ in-the-making
I Bob, thanks for your reply. I tried what you suggest, but the problem is that the success function is executed once the action is finished and the popup has close. So at that time the parameters are not available anymore (This is my guess, as i executed the javascript with the browser console opened and it works as you suggested).
Any ideas?
Thanks for your reply and help!

rjohnson
Star Contributor
Star Contributor
OK. Here's the detailed plan. When you click OK the dialog sends what you have input to a webscript. This web script sends a response (usually JSON but thats up to the way you define it) back to the caller and that response goes to success or failure callback function.

So, write a webscript that your dialog will post to that returns the parameters you send to the caller (just iterate through the args array and reflect it back in the response JSON). Then in the nn success function, pick up the JSON get the args and redirect.

That should do the job.

jmoyano
Champ in-the-making
Champ in-the-making
Hi Bob, I finally managed to make this redirection with some javascript calls that i add to my custom component that is rendered in the form. However, seems that your solution might be better, but I am a completely newbie in alfresco, and I don't know how to do what you suggested me. Is there any similar example to what you suggest that I can look at? Not the javascript or webscript itself, but the configuration to set this flow.
Best regards and thanks again!