com.ebasetech.xi.services
Class VelocityServices

java.lang.Object
  extended by com.ebasetech.xi.services.VelocityServices

public class VelocityServices
extends java.lang.Object

VelocityServices provides static methods to invoke a Velocity template.

Since:
V4.4

Field Summary
static int LOG_LEVEL_DEBUG
          Debug log level (value 0)
static int LOG_LEVEL_ERROR
          Error log level (value 3)
static int LOG_LEVEL_INFO
          Info log level (value 1)
static int LOG_LEVEL_WARN
          Warn log level (value 2)
 
Constructor Summary
VelocityServices()
           
 
Method Summary
static java.lang.String invokeTemplateFromFile(java.lang.String fileName)
          This is equivalent to invoking method invokeTemplateFromFile(String, int) with log level warn.
static java.lang.String invokeTemplateFromFile(java.lang.String fileName, int logLevel)
          Invokes the Velocity template contained in the file specified by fileName.
static java.lang.String invokeTemplateFromInlineString(java.lang.String templateString)
          This is equivalent to invoking method invokeTemplateFromInlineString(String, int) with log level warn.
static java.lang.String invokeTemplateFromInlineString(java.lang.String templateString, int logLevel)
          Invokes the Velocity template contained in parameter templateString.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 Detail

VelocityServices

public VelocityServices()
Method Detail

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:

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:

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