Class VelocityServices

java.lang.Object
com.ebasetech.xi.services.VelocityServices
All Implemented Interfaces:
java.io.Serializable

public class VelocityServices
extends java.lang.Object
implements java.io.Serializable
VelocityServices provides static methods to invoke a Velocity template.
Since:
V4.4
See Also:
Serialized Form
  • Field Details

    • LOG_LEVEL_DEBUG

      public static final int LOG_LEVEL_DEBUG
      Debug log level (value 0)
      See Also:
      Constant Field Values
    • LOG_LEVEL_INFO

      public static final int LOG_LEVEL_INFO
      Info log level (value 1)
      See Also:
      Constant Field Values
    • LOG_LEVEL_WARN

      public static final int LOG_LEVEL_WARN
      Warn log level (value 2)
      See Also:
      Constant Field Values
    • LOG_LEVEL_ERROR

      public static final int LOG_LEVEL_ERROR
      Error log level (value 3)
      See Also:
      Constant Field Values
  • Constructor Details

    • VelocityServices

      public VelocityServices()
  • Method Details

    • invokeTemplateFromInlineString

      public static java.lang.String invokeTemplateFromInlineString​(java.lang.String templateString) throws com.ebasetech.xi.exceptions.FormRuntimeException
      This is equivalent to invoking method invokeTemplateFromInlineString(String, int) with log level warn.
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException
      Since:
      V4.4
    • invokeTemplateFromInlineString

      public static java.lang.String invokeTemplateFromInlineString​(java.lang.String templateString, int logLevel) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Invokes the Velocity template contained in parameter templateString. This provides integration with the Velocity template engine supplied by Apache.

      The logging level controls the level of generated messages, and any such messages are written to the designer execution log (View > Execution log). Available log levels are:

      • 0 debug (constant LOG_LEVEL_DEBUG)
      • 1 info (constant LOG_LEVEL_INFO)
      • 2 warn (constant LOG_LEVEL_WARN)
      • 3 error (constant LOG_LEVEL_ERROR)
      Further documentation.

      Javascript example:

       var template = "<table border='0'> " +
         "#foreach ( $row in $ORDERS ) " +
         "<tr> " +
           "<td>Order Number: ${ORDERS-ORDER_NUMBER}</td>" +
           "<td>Order Value: ${ORDERS-ORDER_VALUE}</td> " +
         "</tr> " +
         "#end " +
         "</table>";
       fields.RESULT.value = VelocityServices.invokeTemplateFromInlineString(template, VelocityServices.LOG_LEVEL_WARN);
       
      Parameters:
      templateString - the Velocity template string
      logLevel - see above
      Returns:
      the result of executing the template
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs
      Since:
      V4.4
    • invokeTemplateFromFile

      public static java.lang.String invokeTemplateFromFile​(java.lang.String fileName) throws com.ebasetech.xi.exceptions.FormRuntimeException
      This is equivalent to invoking method invokeTemplateFromFile(String, int) with log level warn.
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException
      Since:
      V4.4
    • invokeTemplateFromFile

      public static java.lang.String invokeTemplateFromFile​(java.lang.String fileName, int logLevel) throws com.ebasetech.xi.exceptions.FormRuntimeException
      Invokes the Velocity template contained in the file specified by fileName. This provides integration with the Velocity template engine supplied by Apache.

      Only a file name can be specified for the template location, not a complete file path. All templates must be located in the directory specified in parameter file.resource.loader.path of properties file velocity.properties.

      The logging level controls the level of generated messages, and any such messages are written to the designer execution log (View > Execution log). Available log levels are:

      • 0 debug (constant LOG_LEVEL_DEBUG)
      • 1 info (constant LOG_LEVEL_INFO)
      • 2 warn (constant LOG_LEVEL_WARN)
      • 3 error (constant LOG_LEVEL_ERROR)
      Further documentation.

      Javascript example:

       fields.F1.value = VelocityServices.invokeTemplateFromFile("template1.vm", VelocityServices.LOG_LEVEL_DEBUG);
       
      Parameters:
      fileName - the file name of the Velocity template
      logLevel - see above
      Returns:
      the result of executing the template
      Throws:
      com.ebasetech.xi.exceptions.FormRuntimeException - if any error occurs
      Since:
      V4.4