Adding a 'configure' page to my Add-On in confluence.
Asked by Stephen Swavley:

I have written a Confluence Macro that needs the admin to setup a default value that will be system wide. My macro will then need to pull this default value and use it. At the moment I have simply hard coded it in my Macro. Obviously this is not desirable as I would have to modify the Macro for every system that uses it.

I believe that this should be done using the 'configure' button from the Add-Ons page for my Macro.

I have been looking for some sample code of a Macro that has this in it but can't find any and am at a loss as to how to find out how to do this.

Can anyone give me some tips/hints/ideas where I might find out how to do this?


Answers:
author: David at David Simpson Apps
body: Hi Stephen

Take a look at the Markdown for Confluence add-on, particularly the **ConfigurationServlet** and the soy template **md-configure.soy**:

**ConfigurationServlet:** [](https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/java/me/davidsimpson/confluence/addon/markdown/servlet/ConfigurationServlet.java?at=master)<https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/java/me/davidsimpson/confluence/addon/markdown/servlet/ConfigurationServlet.java?at=master>

**md-configure.soy:** [](https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/resources/soy/md-configure.soy?at=master)<https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/resources/soy/md-configure.soy?at=master>

**atlassian-plugin.xml:** [](https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/resources/atlassian-plugin.xml?at=master#cl-65)<https://bitbucket.org/dvdsmpsn/markdown-for-confluence/src/6f97807fc7abc919cb325dc3e1a2d0e8b12c884c/src/main/resources/atlassian-plugin.xml?at=master#cl-65>

In the plugin xml file look at the following (I've stripped out the bits that aren't for the config page):

```
&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"&gt;  &lt;plugin-info&gt;    ...	...    &lt;param name="configure.url"&gt;/plugins/servlet/markdown-for-confluence/configure&lt;/param&gt;&lt;-- the link in the UPM --&gt;  &lt;/plugin-info&gt;    ...  ...  &lt;!-- the servelet --&gt;  &lt;servlet name="Configuration Servlet" i18n-name-key="configuration-servlet.name" key="configuration-servlet" class="me.davidsimpson.confluence.addon.markdown.servlet.ConfigurationServlet"&gt;    &lt;description key="configuration-servlet.description"&gt;The Configuration Servlet Plugin&lt;/description&gt;    &lt;condition class="com.atlassian.confluence.plugin.descriptor.web.conditions.ConfluenceAdministratorCondition" /&gt;    &lt;url-pattern&gt;/markdown-for-confluence/configure&lt;/url-pattern&gt;  &lt;/servlet&gt;  &lt;!-- soy template for the servlet --&gt;  &lt;web-resource key="configure-soy"&gt;    &lt;transformation extension="soy"&gt;      &lt;transformer key="soyTransformer"/&gt;    &lt;/transformation&gt;    &lt;resource type="download" name="md-configure.js" location="soy/md-configure.soy"/&gt;  &lt;/web-resource&gt;  &lt;!-- link in the left hand navigation of the confluence admin section --&gt;  &lt;web-item key="markdown-for-confluence.configure" name="Markdown Configure Link" weight="10000" section="system.admin/configuration"&gt;    &lt;description&gt;Link to configure action&lt;/description&gt;    &lt;label key="me.davidsimpson.confluence.addon.markdown-for-confluence.configure.web-item"/&gt;    &lt;link&gt;/plugins/servlet/markdown-for-confluence/configure&lt;/link&gt;    &lt;condition class="com.atlassian.confluence.plugin.descriptor.web.conditions.ConfluenceAdministratorCondition" /&gt;  &lt;/web-item&gt;  &lt;!-- Some plumbing to help out --&gt;  &lt;component-import key="loginUriProvider" interface="com.atlassian.sal.api.auth.LoginUriProvider"/&gt;  &lt;component-import key="pluginSettingsFactory" interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory"/&gt;  &lt;component-import key="soyTemplateRenderer" interface="com.atlassian.soy.renderer.SoyTemplateRenderer"/&gt;  &lt;component-import key="templateRenderer" interface="com.atlassian.templaterenderer.TemplateRenderer"/&gt;  ...  ...  &lt;/atlassian-plugin&gt;
```

Traditionally people used velocity for configuration screens, but servlets + Soy means that you can use the same kind of code in Confluence, JIRA and other add-ons, so it's quite nice.

<br />


Tags: app

macro