Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi, I'm new to confluence and am working on my first User Macro. It has 1 parameter, html and javascript (that's rendered). The html and javascript comprise a multi-picker. I want to use the picker to set the value of the parameter but I can't figure out how to save the result.
From javascript, how do I set the value of a user macro parameter?
Right now, when I save.. the picker appears in the page that's created rather than the values I selected – despite the fact that I programmatically remove it before saving.
As I understand it, user macros are executed when the page template is rendered, which is before executing JavaScript. You need for the JavaScript to leave its state, and then reload the page, with the macro picking up the value when it is re-rendering. I've done that using HTML parameters.
You can get HTML parameters from the $req object, which is the current servlet request object, and is available in the Velocity context.
#set($value=$!req.getParameter("paramName")) #if ($value) ## use that as the parameter value #else ## Use the default parameter or whatever you have #end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.