There are two frameworks that do the template rendering in Confluence: Struts and Sitemesh. Maybe confusingly, they both use Velocity as their templating engine. We try to distinguish between them by using *.vm for templates processed by Struts, and *.vmd for those processed by Sitemesh.
There are four different Velocity contexts used in Confluence:
#applyDecorator()
directive use the context defined in ApplyDecoratorDirectiveThe two Sitemesh contexts are almost identical, but the Struts Velocity context contains more items than either of the Sitemesh ones.
The following diagram shows the logical structure of the Confluence UI.
Confluence UI Architecture - Logical Structure
The following diagram shows the flow of control through the Confluence UI.
Confluence UI Architecture - Execution Flow
In more detail, the flow of control goes:
#applyDecorator()
directive:
#decoratorParam()
directives are processed by the ParamDirective class, which pushes bits of the current Velocity context into the ApplyDecoratorDirective parametersYou can find out which beans are in which context by looking in the classes above. A full list would be too long to include here. Note that even though the ApplyDecoratorDirective launches a Sitemesh decorator template, the Sitemesh template doesn't get automatic access to the Velocity context. The only bits that are passed through are done with the #decoratorParam()
directive.
Wow, pretty complicated. But it lets us do cool stuff like implement custom themes, apply layouts and more.
Rate this page: