Confluence Docs 3.0 : Velocity Context Plugins This page last changed on Nov 03, 2008 by smaddox.
| Velocity Context plugin modules are available in Confluence 1.4 and later
Velocity Context plugin modules enable you to add components to Confluence's velocity context, making those components available in templates rendered from decorators, themes, XWork actions or macros. For more information about plugins in general, read Confluence Plugin Guide. To learn how to install and configure plugins (including macros), read Installing and Configuring Plugins Manually. For an introduction to writing your own plugins, read Writing Confluence Plugins ## Velocity Context Plugin Module Each component module adds a single object to Confluence's default velocity context. This context is the collection of objects that are passed to each velocity template during rendering of macros, decorators, themes and XWork actions. This allows you to create helper objects that perform tasks too complex to represent in Velocity templates. The objects are autowired by Spring before being added to the context. Here is an example `atlassian-plugin.xml` file containing a single velocity context module:
    <atlassian-plugin name="Sample Component" key="confluence.extra.component">
        ...
        <velocity-context-item key="myVelocityHelper"
              name="My Plugin's Velocity Helper" context-key="myVelocityHelper"
              class="com.example.myplugin.helpers.MyVelocityHelper" />
        ...
    </atlassian-plugin>
the name attribute represents how this component will be referred to in the Confluence interface. the key attribute represents the internal, system name for your component. the context-key attribute represents the variable that will be created in Velocity for this item. So if you set a context-key of `myVelocityHelper`, the object will be available as `$myVelocityHelper` in Velocity templates the class attribute represents the class of the component to be created. The class must have a no-argument constructor, or it will not be able to be instantiated by Confluence.

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