To persist the configuration of a theme you can make use of the Bandana persistence framework. For example, the Left Navigation Theme uses the persister to store it's configuration values.
The recommended way of saving the settings, is to create a simple configuration bean which implements the Serializable interface. The bean for the Left Navigation Theme for example, simply consists of two String variables and their getter and setter methods.
1 2package com.atlassian.confluence.extra.leftnavigation; import java.io.Serializable; public class LeftNavSettings implements Serializable { private String space; private String page; public String getSpace() { return space; } public void setSpace(String space) { this.space = space; } public String getPage() { return page; } public void setPage(String page) { this.page = page; } }
Bandana can be used to save a configuration object with a given context, where the context refers to a space. The setValue function of the BandanaManager has three arguments:
1 2// Create a setting bean. LeftNavSettings settings = new LeftNavSettings(); settings.setSpace("example Space"); settings.setPage("example Page"); // Save the bean with the BandanaManager bandanaManager.setValue(new ConfluenceBandanaContext(spaceKey), THEMEKEY, settings);
A Context can be defined on two levels:
The configuration object can be retrieved by using bandanaManager.getValue. This method will get the configuration object, starting with the given context and looking up in the context hierarchy if no context is found.
1 2LeftNavSettings settings = (LeftNavSettings) bandanaManager.getValue(new ConfluenceBandanaContext(spaceKey), THEMEKEY);
Rate this page: