Confluence Docs 3.0 : Saving Theme Configurations with Bandana This page last changed on Nov 14, 2006 by jnolen. 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. ## Defining a Settings Bean 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.
    package 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;
        }
    }
## Saving the Bean 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: @param context The context to store this value in @param key The key of the object @param value The value to be stored
    // 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: Global: new ConfluenceBandanaContext() Space level: new ConfluenceBandanaContext(spaceKey)
## Retrieving the Bean 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. @param context The context to start looking in @param key The key of the BandanaConfigurationObject object @return Object object for this key, or null if none exists.
    LeftNavSettings settings = (LeftNavSettings) bandanaManager.getValue(new ConfluenceBandanaContext(spaceKey), THEMEKEY);

Document generated by Confluence on Nov 05, 2009 23:34