Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Confluence User Macro Dynamic Parameter Descriptions

Jonathan Martin July 8, 2014

I've persisted some plugin configuration data using the PluginSettingsFactory interface. I'm able to access the values of this data in my com.atlassian.confluence.macro.Macro implementation class by injecting the PluginSettingsFactory interface.

However, I'd like to use some of this configuration data in the description of one of the parameters for the form displayed on my user macro.

I've looked into using AJS.MacroBrowser.setMacroJsOverride("<macro-name>", jsOverrides) on the client. This allows me to manipulate the description field but I need to have access to the configurable data.

Is there anyway I can get to the PluginSettingsFactory data in my client JS? Or better yet, is there any way I could manipulate the parameter description before the form is rendered on the server?

I've been searching the Google, Confluence API and reference docs for half a day. I'm sure there's a simple solution just not sure what it is.

Any help is greatly appreciated.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Jonathan Martin July 9, 2014

I was able to read through the code mentioned under the "Transforms that do variable injection" heading and can now access my configurable data on the client.

https://developer.atlassian.com/display/DOCS/Stateless+web-resource+transforms+and+conditions

Jonathan Martin July 9, 2014

I am able to access the data I need but now would like the data to only be available in the context of my plugin. Otherwise I'm hitting the database with every request when the data isn't needed in every request. Right now I'm using the atl.general context as follows:

&lt;web-resource key="product-blueprint-plugin-data"&gt;
 &lt;context&gt;atl.general&lt;/context&gt;
        &lt;dependency&gt;com.atlassian.plugins.atlassian-plugins-webresource-plugin:data&lt;/dependency&gt;
        &lt;data key="product-blueprint-plugin-data" class="&lt;my-root-package&gt;.confluence.plugins.productblueprint.ProductBlueprintPluginDataProvider" /&gt;
        &lt;resource type="download" name="product-blueprint-plugin-data.js" location="&lt;my-root-path&gt;/confluence/plugins/productblueprint/js/plugin-data.js" /&gt;
&lt;/web-resource&gt;

I found that this article under the "Introducing new contexts" heading mentions referencing a new context in a Velocity template. However, it appears that doing this doesn't include the macro's param form as part of the context so I can't access my data.

Any help would be greatly appreciated.

Jonathan Martin July 9, 2014

I should have read a little further in the article mentioned above. There are some more specific Confluence contexts. I settled on the "macro-browser" context. It still looks like it's called with every page just not as many times as with the "atl.general" context.

It'd be nice if there was a context for the "macro-preivew" dialog.

TAGS
AUG Leaders

Atlassian Community Events