How can I add `space` character in the "name" of xhtml-macro parameter? Edited

There is the following xthml-macro:  

<xhtml-macro name="pinkbutton" class="ro.fortech.att.confluence.macro.PinkButtonMacro" key='pinkbutton'>
<description>PinkButton</description>
<category name="confluence-content"/>
<parameters>
<parameter name="label" required="true" type="string"/>
<parameter name="link" type="string" required="true"/>
</parameters>
</xhtml-macro>  

And also the following class:  

public class PinkButtonMacro extends FortechBaseMacro {
private static final String MACRO_BODY_TEMPLATE = "components/pinkbutton.vm";

@RequiresFormat(Format.View)
public String execute(Map<String, String> params, String body, ConversionContext conversionContext) throws MacroExecutionException {
Map<String, Object> context = MacroUtils.defaultVelocityContext();

putParamIfExists_EmptyTextIfNot(params, context, "label");
putParamIfExists_EmptyTextIfNot(params, context, "link");

return VelocityUtils.getRenderedTemplate(MACRO_BODY_TEMPLATE, context);
}

 

What I want is to replace the parameter name "label" to "Button label" and "link" to "Button link". The problem occures in the `execute` method because of the params.

Is there a way to get the params if there is a space character in the xhtml-macro parameter name?

 

1 answer

1 accepted

0 vote
Stephen Deutsch Community Champion Aug 09, 2017

As far as I know, parameters cannot have spaces. Most of the time dashes are used instead, so button-label and button-link. If you want a different name to appear in the editor window, then you'll need to include it in the .properties file. See the example here for more details:

https://bitbucket.org/resah/confluence-macro-tutorial/src/d3b508ea01a78abdfb0a482a1bd3e477bb4be123/src/main/resources/?at=default

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

485 views 19 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you