Package com.ebasetech.xi.services
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 Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description VelocityServices()
-
Method Summary
Modifier and Type Method Description static java.lang.String
invokeTemplateFromFile(java.lang.String fileName)
This is equivalent to invoking methodinvokeTemplateFromFile(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 byfileName
.static java.lang.String
invokeTemplateFromInlineString(java.lang.String templateString)
This is equivalent to invoking methodinvokeTemplateFromInlineString(String, int)
with log level warn.static java.lang.String
invokeTemplateFromInlineString(java.lang.String templateString, int logLevel)
Invokes the Velocity template contained in parametertemplateString
.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
LOG_LEVEL_DEBUG
public static final int LOG_LEVEL_DEBUGDebug log level (value 0)- See Also:
- Constant Field Values
-
LOG_LEVEL_INFO
public static final int LOG_LEVEL_INFOInfo log level (value 1)- See Also:
- Constant Field Values
-
LOG_LEVEL_WARN
public static final int LOG_LEVEL_WARNWarn log level (value 2)- See Also:
- Constant Field Values
-
LOG_LEVEL_ERROR
public static final int LOG_LEVEL_ERRORError 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.FormRuntimeExceptionThis is equivalent to invoking methodinvokeTemplateFromInlineString(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.FormRuntimeExceptionInvokes the Velocity template contained in parametertemplateString
. 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
)
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 stringlogLevel
- see above- Returns:
- the result of executing the template
- Throws:
com.ebasetech.xi.exceptions.FormRuntimeException
- if any error occurs- Since:
- V4.4
- 0 debug (constant
-
invokeTemplateFromFile
public static java.lang.String invokeTemplateFromFile(java.lang.String fileName) throws com.ebasetech.xi.exceptions.FormRuntimeExceptionThis is equivalent to invoking methodinvokeTemplateFromFile(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.FormRuntimeExceptionInvokes the Velocity template contained in the file specified byfileName
. 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 filevelocity.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
)
Javascript example:
fields.F1.value = VelocityServices.invokeTemplateFromFile("template1.vm", VelocityServices.LOG_LEVEL_DEBUG);
- Parameters:
fileName
- the file name of the Velocity templatelogLevel
- see above- Returns:
- the result of executing the template
- Throws:
com.ebasetech.xi.exceptions.FormRuntimeException
- if any error occurs- Since:
- V4.4
- 0 debug (constant
-