Description

The VelocityContextObject is a Velocity Context Object for the OpenCms Module "at.infonova.opencms.modules.velocity" from Infonova Gmbh.

OpenCms is a Content Management System that is based on Open Source Software. Complex Intranet and Internet websites can be quickly and cost-effectively created, maintained and managed.

Config

This ContextObject must be configured in "WEB-INF/config/infonova-velocity.xml".

The entry could look like the following:

<opencms>
  <velocity>
    <velocity-context-objects>
      [...]
      <velocity-context-object
        name="velocity"
        factory-class="at.infonova.opencms.modules.velocity.contextobjects.VelocityContextObject$Factory" />
    </velocity-context-objects>
  </velocity>
</opencms>

After configuration the ContextObject a reboot of OpenCms is required.

Example Usage

After configuration the ContextObject it is available in all Velocity templates which are parsed by the OpenCms Module "at.infonova.opencms.modules.velocity" from Infonova Gmbh.

The default prefix of this ContextObject should be 'velocity'.

After that, the following Methods are available:

  • ${velocity.help} => This helptext.
  • ${velocity.helpAll} => helptexts of all available Obejcts in this Velocity Context.
  • ${velocity.include( java.lang.String resourcePath)} => include the given Velocity File (use the current Velocity context).
  • ${velocity.include( java.lang.String resourcePath, java.util.Map params)} => include the given Velocity File wtih the given params (create a new Velocity context).
  • ${velocity.initContextObject( java.lang.String name, java.lang.String factoryClass)} => Initialize a new ContextObject with the given ContextObjectFactory Class and register it into the current context with the given name.