Description

The FunctionsContextObject 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="fn"
        factory-class="at.infonova.opencms.modules.velocity.contextobjects.FunctionsContextObject$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 'fn'.

After that, the following Methods are available:

  • ${fn.help} => This helptext.
  • ${fn.contains( java.lang.String input, java.lang.String substring) => Tests if an input string contains the specified substring.
  • ${fn.containsIgnoreCase( java.lang.String input, java.lang.String substring) => Tests if an input string contains the specified substring in a case insensitive way.
  • ${fn.endsWith( java.lang.String input, java.lang.String substring) => Tests if an input string ends with the specified suffix.
  • ${fn.escapeXml( java.lang.String input) => Escapes characters that could be interpreted as XML markup.
  • ${fn.escapeHtml( java.lang.String input) => Escapes characters that could be interpreted as HTML markup.
  • ${fn.escapeJavaScript( java.lang.String input) => Escapes characters that could be interpreted as JavaScript markup.
  • ${fn.indexOf( java.lang.String input, java.lang.String substring) => Returns the index withing a string of the first occurrence of a specified substring.
  • ${fn.join( java.lang.String[] array, java.lang.String separator) => Joins all elements of an array into a string.
  • ${fn.length( java.lang.Object obj) => Returns the number of items in a collection, or the number of characters in a string.
  • ${fn.isEmpty( java.lang.Object obj) => Returns true if a collection, or a string is Empty.
  • ${fn.replace( java.lang.String input, java.lang.String substringBefore, java.lang.String substringAfter) => Returns a string resulting from replacing in an input string all occurrences of a "before" string into an "after" substring.
  • ${fn.split( java.lang.String input, java.lang.String delimiters) => Splits a string into an array of substrings.
  • ${fn.startsWith( java.lang.String input, java.lang.String substring) => Tests if an input string starts with the specified prefix.
  • ${fn.substring( java.lang.String input, int beginIndex, int endIndex) => Returns a subset of a string.
  • ${fn.substringAfter( java.lang.String input, java.lang.String substring) => Returns a subset of a string following a specific substring.
  • ${fn.substringBefore( java.lang.String input, java.lang.String substring) => Returns a subset of a string before a specific substring.
  • ${fn.toLowerCase( java.lang.String input) => Converts all of the characters of a string to lower case.
  • ${fn.toUpperCase( java.lang.String input) => Converts all of the characters of a string to upper case.
  • ${fn.trim( java.lang.String input) => Removes white spaces from both ends of a string.