groovyxwiki

Execute a groovy script on click in XWiki


I can't figure out how to run a simple groovy script in xwiki when clicking on a link/button? I don't want the script to be started when the xwiki page is loaded. The script itself is working fine but how can I connect the script with an push event on the button?

Is there any easy way to implement this?


Solution

  • The strategy is to use the HTML macro, use an HTML format and call the same page but passing a parameter to recognize that the button has been clicked. If you want a link, simply call the same page using for example [[label>>||queryString="confirm=1"]] and then do an #if in Velocity.

    Here's an example: https://www.xwiki.org/xwiki/bin/view/FAQ/How%20can%20I%20create%20a%20new%20page%20based%20on%20a%20form