Can a plugin macro on a page access a query string parameter included in the request URL for the page?
Example:
http://exampledomain.com/display/spacekey/Home?myquerystringparameter=X
in macro sited on Home page, run the following code.
public class MyMacro implements Macro { @Override public String execute(Map<String, String> parameters, String bodyContent, ConversionContext conversionContext) throws MacroExecutionException { // some API to consume query string parameter? Object myQueryStringParam = someAPI('myquerystringparameter'); ...
My question is what API, if any, can I use to consume the query string parameter?
Community moderators have prevented the ability to post new answers.
import com.opensymphony.webwork.ServletActionContext; import javax.servlet.http.HttpServletRequest; // then use this HttpServletRequest request = ServletActionContext.getRequest(); string param = request.getParameter("myquerystringparamter"));
Thats pretty straighforward.
Perfect. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In what language is that code written? I mean, what macro do I have to select and then paste that code into its body? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
They are talking about a formal java macro built in a plugin. You should be able to use the same technique in a Groovy Macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great! At last! You only have to add a groovy macro and then paste this code:
def p=request.getParameter("p") println(p)
"Save" and then, if you call that page adding this to the URL:
?p=v
...a "v" is shown.
Thanks Bob!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good. Nice idea to take advantage of the request pre-defined variable to make it easier when used in groovy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi!
have a look at the free plugins from randombits. they contain lots of very usefull features and are highly recommended
e.g. from confluence support plugin which you can get from here:
https://marketplace.atlassian.com/plugins/org.randombits.support.support-core
check out this:
cheers,
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.