It appears that when using the user macro browser, default parameter values are not being passed to the user macro.
For example, when using the following:
## @param locations:title=Locations|type=string|required=false|default=all|desc=The locations to report on.
If the parameter value is left as the default all by the user, an empty/null value is passed to the user macro instead of the expected all.
This is an issue in Confluence 4.2 as well.
As a workaround, you can check each parameter for a null value using Velocity, and in that case apply your chosen defaults. From an end-user perspective things work as they should like this.
Example:
##Check default values (bug in Confluence - https://jira.atlassian.com/browse/CONF-23704) #if(!$paramoddcolor) #set($paramoddcolor = "ffffff") #end #if(!$paramevencolor) #set($paramevencolor = "ededed") #end
Hi Stuart,
I think you're hitting this reported bug https://jira.atlassian.com/browse/CONF-23704
I'm seeing the same behaviour as well, but have observed that if the value a user provides is the same as the default value then the value is not passed to the macro. If the user provides anything that is different to the default value then the user provided value is passed to the macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to add to this, an example of a macro that shows this problem is:
## @param myname:title=myname|type=string|desc=descy|required=true|default=MY DEFAULT VALUE <div id="$parammyname"> $parammyname </div>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian didn't understand my problem here, so this may help to explain it:
The problem occurs when creating and using a User Macro. At the top of the macro code I define a parameter in the following way:
## @param locations:title=Locations|type=string|required=false|default=all|desc=The locations to report on.
The User Macro browser then understands that this particular macro can accept a parameter called "locations". As I have set a default value of "all" in the line shown above, the User Macro browser shows that "all" value by default in the field for that parameter. The problem occurs at this point if the user decides to go with the default value of "all" for this parameter. I am finding that in that case, the "location" parameter's default value of "all" is not being passed to the User Macro code. The value of the "location" parameter is only passed to the User Macro code if the user decides not to use the default value and gives their own value instead.
If predefined default values are not being sent to the User Macro code then what is the purpose of setting them?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.