Velocity

Velocity is a template language whose purpose is to generate content. This means: HTML, XML, JSON - or whatever format is needed - is enriched with data from the database, calculations or other data sources. This can be either to exchange data in a certain format or simply to display this content in the browser. Java objects, which Intrexx provides, are used to determine the data. However, it is also possible to include objects from your own Java classes. The API provides a number of access methods to important Intrexx functionalities and objects.

Click here for general information about scripting in Intrexx.

Intrexx Standard Library

In the Velocity script editor, you can access the Intrexx Standard Library on the libraries tab. If you select an entry in the library, you can access these buttons at the bottom right of this area:

Show description

Shows the description of the currently selected function with an example script.

Open link

Links to the corresponding page that provides more information. The page that opens also shows the classes, interfaces, methods or properties that the currently selected function can be used for. This opens the exact page with the classes, interfaces, methods or properties that you can use for the currently selected function.

Application structure

Application info

Information about the application with the stated GUID.

Example

#set($appInfo = $RtCache.getApplication("C6F004594EEA424B2AACCD105181AD7F0660DF6D").getStartFupGuid())

Returns the GUID of the application's start page.

Snippet

$RtCache.getApplication("")

Interface ApplicationInfo

Data group info

Information about the data group with the stated GUID.

Example

#set($dgInfo = $RtCache.getDataGroup("93B1A993C5FCF2895C93E1B7BF3BDDC847DC2BCD").getName())

Returns the name of the data group.

Snippet

$RtCache.getDataGroup("")

Interface DataGroupInfo

Data field info

Information about the data field with the stated GUID.

Example

#set($fldInfo = $RtCache.getField("8E2B87AE9F9BD1FD2FE38AD6856347F3A0D358AD").getName())

Returns the name of the data field.

Snippet

$RtCache.getField("")

Interface FieldInfo

Page info

Information about the page with the stated GUID.

Example

#set($pageInfo = $RtCache.getPage("D867C6B9AC0D17E3F524ED5A5E164463046F8F01")isEditPage())

Returns true if the page is an edit page, otherwise returns false.

Snippet

$RtCache.getPage("")

Interface PageInfo

Current user

Login name of current user

Returns the login name of current user.

Snippet

$User.getLoginName()

Interface IUser

Email address of current user

Returns the business email address of current user.

Snippet

$User.getEmailBiz()

Interface IUser

Determine user memberships

Determine group memberships of the current user and execute further actions based on this.

Snippet

#set($groupGuids = ['EF16F15EDA8562E19D7CD56BF2E43001F119193C', '47DD42CF4203EFDC7B1596E0158BB5B1E810D583'])
#set($userMembership = $Portal.getOrgStructure().getMembershipSets($User))

##Returns true, if $User is member of at least one group, which is defined by its guid in $groupGuids
#if ($userMembership.intersects($groupGuids))
	##Not implemented yet
#end

Class VelocityOrgStructureWrapper

Objects in the Velocity context

$AccessController

Object that can be used to check access permissions to applications, data groups etc.

Snippet

$AccessController

Class IxAccessController

$AppUserProfile

Save data persistently per user.

Snippet

$AppUserProfile

Class VCApplicationUserProfile

$AsynchronousRequestHandler

Object for processing asynchronous requests.

Snippet

$AsynchronousRequestHandler

Class AsynchronousRequestHandlerCallable

$BCM

Object for accessing the cache manager and the update sequence number (USN) of individual objects.

Snippet

##Gets the USN of the view page
$BCM.getUsn("viewpage971CA7D9")

Class BrowserCacheManager

Binding

Access to all bindings that are available at the time of access.

System data groups

$Binding.getValue("systemDataGroup.dataField['SYSDGFIELD_GUID']", "defaultvalue").asString()

Example

$Binding.getValue("systemDataGroup['APP_GUID'].dataField['SYSDGFIELD_GUID']", "defaultvalue").asString()

You can also access system data groups from other applications. You can also access system data groups from other applications. Enter the GUID of the APP after "systemDataGroup":

Value from tables

$Binding.getValue("dataRange['<GUID of tablerecords>'].row['0'].control['<GUID of column / control>']")

Access values of a table - not possible with calculated values, multiple selection, dynamic view.

The script example returns an IIxValue.

Use the GUID of the table records. The GUID can be determined when all elements of the table are displayed in the application structure. This can be done via the main menu "Edit" if the table is selected in the table is selected in the application structure.

$Binding.getValue("dataRange['<GUID of tablerecords>'].row['0'].control['<GUID of column / control>']").asString()
        

Returns an unformatted string.

$Renderer.renderDateTime($Binding.getValue("dataRange['<GUID of tablerecords>'].row['1'].control['<GUID of column / control>']").asValueHolder())
        

Renders a date as string.

dataRange['<name of tablerecords>'].row['0'].control['<Name of column / control>']
        

Values can also be determined via the name of the tablerecords / the table column.

dataRange['<name of tablerecords>'].count
        

Returns the number of visible data records of the table.

dataRange['<name of tablerecords>'].totalCount
        

Returns the number of filtered data records in the table.

dataRange['<name of tablerecords>'].row['0'].primaryKey
        

Returns the primary key / the record id of the data record.

Snippet

$Binding

Class IIxValue

$Browser

Object for requesting browser information.

Snippet

##Gets the user agent string of the calling browser
$Browser.getUserAgentId()

Class BrowserCallable

$CalcUtil

Introduction

In the following, the Velocity context object "$CalcUtil" for calculating values will be presented and explained using code examples.

With the function calculate(), complex calculation and comparison operations can be performed.

The '( )' brackets can be used to structure the operation. The values for the calculation and comparison operations being performed can be read from data fields, sessions, requests, table cells or SharedStates.

Operators

The following operators are available in a calculation formula:

  • + (Addition)

  • - (Subtraction)

  • * (Multiplication)

  • / (Division)

  • < (Comparison: Smaller than)

  • > (Comparison: Greater than)

  • <= (Comparison: Smaller than or equal to)

  • >= (Comparison: Greater than or equal to)

  • == (Comparison: Equal)

  • != (Comparison: Unequal)

  • && (Logical connection: And)

  • || (Logical connection: Or)

  • ! (Logial operator: Not)

Other type categories and methods

In addition to the operators described above, there are additional options to call certain variables or methods in formulae:

Method

Description

Example

datafield

Value from a data field

datafield("C68F6...D3DE7")

datafieldAsNumber

Value from a data field as a number

datafieldAsNumber("C68F6...D3DE7")

session

Value from an existing session of the currently logged-in user as a number

session("sessionValue")

sessionAsNumber

Value from an existing session of the currently logged-in user as a number

sessionAsNumber("sessionValue")

sharedState

Value from the current processing context as a number

sharedState("sharedStateValue")

sharedStateAsNumber

Value from the current processing context as a number

sharedStateAsNumber("sharedStateValue")

requestAsNumber

Value from the current request as a number

requestAsNumber("rq_requestValue")

abs

Absolute value

abs(-1)

For the types with the suffix "AsNumber", Intrexx will attempt to cast the incoming values, provided it is technically possible. Without this cast, an exception will occur when you use string data fields, for example. The Boolean values "true" and "false" will be cast accordingly to 1 and 0, respectively. It is also possible to state a fallback as a second method parameter. This fallback is used if the first parameter is null or empty. This fallback value can also be a formula.

Snippet

//returns -1 if the access to the sharedState variable "sharedStateValue" returns null or the value is not set.
sharedState("sharedStateValue", -1)

//returns 5 if the access to the request variable "rq_custom" returns null zurückliefert or the value is not set.
requestAsNumber("rq_custom", (10/2))

//returns 0 if the data field contains null or is not set.
datafield("C68F6...D3DE7", 0)

Error handling

To catch potential errors (e.g. dividing by 0), the following methods can be used in a formula:

Method

Description

Example

zeroOnError

Return of 0 in the case of error

zeroOnError(10/0) == 0

oneOnError

Return of 1 in the case of error

oneOnError(10/0) == 1

fallbackOnError

Returns the fallback value in the case of error

fallbackOnError(10/0, 2) == 2

Rounding functions

Number values can be rounded in formulae. The parameter "scale" describes the number of decimal places.

Method

Description

roundLong

accounting rounding

roundLongHalfAwayFromZero

corresponds to roundLong

roundLongHalfEven

roundLongHalfUp

roundLongHalfDown

round(scale)

accounting rounding on scale decimal places (roundLong corresponds to round(0))

roundLongHalfAwayFromZero(scale)

corresponds to round(scale)

roundLongHalfEven(scale)

roundLongHalfUp(scale)

roundLongHalfUp(scale)

Case differentiation

Conditions in formulae can be checked in advance with case differentiation, and based on their result, certain formulae or values can be used.

case(<booleanExpression>, <formula for true>, <formula for false>)

The following rules are available for the Boolean expression:

  • null == false

  • empty == false

  • 0 == false

  • false == false

  • !true == false

  • !false == true

  • 1 == true

If logical operators are used for the calculation, false becomes 0 and true becomes 1. This results in the following:

5 > 0 + 0 > -1 == 2

Examples

The calculation call with the function "calculate()" on view pages always has three parameters:

  • $ProcessingContext - The current processing context. Value is always fixed.

  • The current data range - $DC for tables and view pages.

  • Formula - Any nested formula desired consisting of the above-mentioned methods and operators.

Simple addition of two values

Here is a simple example for adding values from data fields. o address a data field, you can either state its GUID or the name of the control in single quotation marks.

Example 1

## Parameters of the methode calculate():
## $ProcessingContext (Fixed value)
## $DC 
## '<Name of the control of the 1st summand>'## <Operator>## '<Name of the control of the 2nd summand>'$CalcUtil.calculate($ProcessingContext, $DC, 'dataField("integervcontrol1") + dataField("integervcontrol2")')

##Same example, but here the GUID of the data field instead of the control is used
$CalcUtil.calculate($ProcessingContext, $DC, 'dataField("3BB...5B3") + dataField("C95...950")')

The methods described above can be combined and nested to use values from different sources (session, request etc.).

Example 2

## Combination of data field and session value
$CalcUtil.calculate($ProcessingContext, $DC,'dataField("3BB...5B3") + session("calcutil_example")')

## Combination of data field and request value
$CalcUtil.calculate($ProcessingContext, $DC, 'dataField("floatcontrol02E5") + requestAsNumber("rq_calcUtil")')

## "Smaller" comparison of request value
#set($term = '(dataField("B5F472ED66DCA878683B52CE8F979F4F1DDA172B") * 2) + session("calcutil_value") <requestAsNumber("rq_calcUtil")')
$CalcUtil.calculate($ProcessingContext, $DC, $term)

## Case distinction of request value
#set($term = '(dataField("B5F472ED66DCA878683B52CE8F979F4F1DDA172B") * 2)')
$CalcUtil.calculate($ProcessingContext, $DC, "case(requestAsNumber('rq_calcUtil') <= 100, $term, -1)")

Aggregate functions for tables

You can also process values from table columns using "$CalcUtil". The calculation operations listed in the table below are available for this: The call of methods for tables always have two parameters:

  • Table object

    Access a table - either via the table name or GUID. These are not the direct name or GUID of the table control but rather the values of the attribute "tablerecords" for view tables and "shapedtablebase" for free layout tables. To identify the values, select Edit menu / Show elements, while the page with the table is selected in the application structure. Then navigate through the structure of the desired table. You will find the entry "tablerecords" or "shapedtablebase", respectively. You can determine the name and GUID of the entry in the respective Details dialog.

  • Formula

    Formula with any number of levels. Access column values with row(<column name>) or rowAsNumber(<column name>).

Example 1

$CalcUtil.calculate($ProcessingContext, $DC, 'sum(table("8E9...1B3"), row("integervcontrol3621234C"))')
$CalcUtil.calculate($ProcessingContext, $DC, 'sum(table("8E9...1B3"), row("integervcontrol3621234C"))')

The values are calculated when the page is opened. If the table has a navigation element and this is used, the values of the Velocity statements and calculations are not updated because they the table is reloaded dynamically via AJAX. If you want to perform table calculations after navigation within the table, the corresponding VTL Include (or VM) need to also be reloaded via AJAX. As a workaround, we recommend creating the table to be calculated in such a way that navigation is not required.


Method

Description

sum

Calculates the sum of the column values from the data that is displayed on the current page.

min

Calculates the minimum of the column values from the data that is displayed on the current page.

max

Calculates the maximum of the column values from the data that is displayed on the current page.

count

Calculates the number of data records shown on the current page.

Please note that the total methods are computation-intensive operations. If you have a large amount of data, you may encounter corresponding delays.

Method

Description

totalSum

Calculates the sum of the column values of all data records.

totalMin

Calculates the minimum of the column values of all data records.

totalMax

Calculates the maximum of the column values of all data records.

totalCount

Calculates the number of all data records.

Please note: If the table does contains no data records, the methods mentioned above return the number 0 as the return value.

Example 2

## Example output of an info text below an article table
#set($sum = 'totalSum(table("8E9F10DCB24CBB4B27FF67A3230CE7753521E1B3"), row("integervcontrol3621234C"))')
#set($count = 'totalCount(table("8E9F10DCB24CBB4B27FF67A3230CE7753521E1B3"), row("floatvcontrol256AC41"))')
$CalcUtil.calculate($ProcessingContext, $DC, $count) items were ordered in a total value 
of $CalcUtil.calculate($ProcessingContext, $DC, $sum) €

$Chat

Object for sending and receiving chat messages.

Snippet

$Chat

Class ChatProxy

$Codec

Object for coding and encoding strings.

Snippet

$Codec.hexEncodeString("www.intrexx.com", "UTF-8")
$Codec.hexDecodeString("7777772E696E74726578782E636F6D")

Class Codec

$CollectionFactory

Object for creating collections.

Snippet

$CollectionFactory.createMap()

Class CollectionFactory

$Constants

Object for accessing the constants of a class.

Snippet

$Constants

Class Constants

$Cookies

Set cookies.

Snippet

#set($cookie = $Cookies.createCookie("myCookie", "test"))
$Response.addCookie($cookie)

Class Cookies

$DC

There are three types of data records relevant to $DC and $drRecord:

1. main data record

The main data record is presented on a page through simple elements, such as edit fields, checkboxes, etc.

2. Data record in a view table

The view table is a list of multiple data records. Each row is one data record in a view table.

3. Data record in a free layout table

The free layout table also presents a list of multiple data records. The main difference to a normal view table is that the free layout table uses an integrated page to present the data records and not the raw data like in a view table. Each repetition of this page is a data record in a free layout table.

Access different values with $DC and $drRecord

The use of $DC and $drRecord depends on the context and record type, respectively. If Velocity is written in the context of the main dataset, e.g. with the Static text element on the page, then $DC can be used to access data from the main dataset.

If Velocity code is written in the context of a data record in a view table, e.g. to transfer data to a JavaScript call, $DC is used to access data of the main data record and $drRecord is used to access data of the respective data record in the view table.

If Velocity code is created in the context of a data record in a free layout table, e.g. because a static text element for each data record has been added to the integrated page,

$DC.getMainPageDC()

is used to access the data of the main data record. Both $DC and $drRecord can be used to access data of the respective data record in a free layout table.

 

Access the
main data record

Access the
current data record in a view table

Access the
current data record in a free layout table

Velocity in the main data record

$DC

not possible

not possible

Velocity in the data record in a view table

$DC

$drRecord

not possible

Velocity in the data record in a free layout table

$DC.getMainPageDC()

not possible

$DC oder $drRecord

$Loader.getDataCollection()

Using $Loader.getDataCollection() is exactly the same as using $DC. It is just a different, longer notation. $Loader.getDataCollection() or $DC can be assigned to a new variable as needed.

It is imperative that you use a completely separate name for this new variable - under no circumstances may $DC be used as the name! $DC is a reserved keyword in Intrexx. This applies to all names of the Velocity context objects in Intrexx.

Snippet

##Returns the record ID of the current record as string
$DC.getRecId()

Interface IWebRowDataCollection

2.3.13.1 User-defined $DC in emails

Manual initialization of context object $DC (short for $Loader.getDataCollection()) for using in emails with content generated from Velocity. With <APP-GUID>, the GUID of the application, which is the source of the data records to be processed, has to be provided. The following conditions must be met:

  • Process has to be triggered by a web event

  • Data record must already exist

  • Objects (e.g. data fields), that are used in Velocity must be on the target page as a control

Snippet

#set($template = $Loader.process($ProcessingContext, "<APP_GUID>", "data"))
#set($DC = $Loader.getDataCollection())

$DC - Read value of a control

Read the value of a control (e.g. value of a view field). Use the name of the control, where the value should be read from, as the parameter. Within free layout tables, use the context object $drRecord instead of $DC.

Example

#set($value = $DC.getValueHolder('textvcontrol1234').getValue())

Snippet

#set($value = $DC.getValueHolder('<CONTROL_NAME>').getValue())

Read value from a system data group

Read a value from a system data group. The name of the data field that the value should be read from needs to be stated as a parameter. Within free layout tables, use the context object $drRecord instead of $DC.

Example

#set($value = $DC.getPropertiesVH().get("STR_COLUMN1").getValue()

Snippet

#set($value = $DC.getPropertiesVH().get("<DATAFIELD_NAME>").getValue()

$DEBUG

Object for inspecting individual objects and elements in more detail.

Snippet

##Provides detailed information about the current user object.
$DEBUG.inspect($User)

Class ObjectInspector

$defaultLanguage

The default language of the portal.

Snippet

$defaultLanguage

$DataTransferCallable

Object for accessing data transfer connections.

Snippet

##Returns the JobHistory of the data transfer job with the transferred GUID.
$DataTransferCallable.getJobExecutions("0460E20ACAC15EDDA0E9B62E1F815D5BFD3F9B8F")

Class DataTransferCallable

$DbUtil

Object for accessing database connections and managing transactions of database operations.

Snippet

#set($conn = $DbUtil.getConnection("IxSysDb"))

Class DatabaseUtil

$DefaultMaker

Snippet

$DefaultMaker

Class DefaultMaker

$DistributionControl

Object for accessing distribution controls

Snippet

$DistributionControl

Class VCDistributionControl

$DoubletService

Object for searching for duplicates in data records of an application.

Snippet

$DoubletService

Class DoubletServiceCallable

$drRecord

Object for accessing the current record in a free layout table. The description of the context object $DC provides more information.

Snippet

$drRecord

Interface IWebRowDataCollection

$DtUtil

Object for date calculations.

Snippet

$DtUtil

Class DateTimeUtil

$ESC

Present characters that are normally escaped in Velocity.

Snippet

##Representation of a rhombus (#)
$ESC.getH()

Class EscapedCharacters

$Error

Object for analyzing exceptions.

Snippet

$Error

Class ErrorObject

$ExceptionUtil

Object for throwing exceptions.

Snippet

$ExceptionUtil.throwException("java.io.FileNotFoundException", "Die angegebene Datei existiert nicht.")

Class VelocityExceptionUtil

Objects for Microsoft Exchange

These objects can only be used in conjunction with the Intrexx MediaGateway.

$ExchangeCallable

Callable for Exchange authentications.

Snippet

$ExchangeCallable.getRequiredFields().isPasswordRequired()

Class ExchangeCallable

$ExchangeConnectionCallable

Callable for Exchange authentications.

Snippet

$ExchangeConnectionCallable.getConnection()

Class ExchangeConnectionCallable

$ExchangeMailboxCallable

Callable for accessing the mailbox of an Exchange user.

Snippet

##Returns the out of office message of the current Exchange user.
$ExchangeMailboxCallable.getOutOfOfficeMessage()

Class ExchangeMailboxCallable

$ExchangeMessageCallable

Callable for accessing message objects.

Snippet

##Saves the message with ID $strMessageId in EML format under $strDestinationPath.
$ExchangeMessageCallable.saveMessageAsEML($strMessageId, $strDestinationPath)

Class ExchangeMessageCallable

$ExchangeItemCallable

Callable for accessing Exchange objects.

Snippet

##Stores attachments of the element with ID $strMessageId under $strDestinationPath.
$ExchangeItemCallable.saveAttachment($strMessageId, $strDestinationPath)

Class ExchangeItemCallable

$ExchangeUserMailboxCallable

Callable for mailbox information of an Exchange user.

Snippet

$ExchangeUserMailboxCallable.getMailboxInfo()

Class ExchangeUserMailboxCallable

$Factory

Generate or access objects such as users without them having been predefined in the Velocity context.

Snippet

$Factory

Class ObjectFactory

$FieldFormatter

Snippet

$FieldFormatter

Class FieldFormatter

$FileHelper

Object for file operations such as inserting a file into an Intrexx data group.

Snippet

##Deletes the file from the data field defined with the GUID 
##and the data set defined with the RecID 1.
$FileHelper.deleteFileFromIntrexx($ProcessingContext, "079A397D11EE732857CD1017C3AC6A55D0D112DA", "1")

Class VCFileHelper

$FileUtil

Object for analyzing files in a folder hierarchy.

Snippet

$FileUtil

Class FileUtil

$Filter

Collection of diverse filters for collections used in the Velocity context.

Snippet

$Filter

Class Filter

$FramesetHelper

Object for creating a new URL based on the current request and a list of additional parameters.

Snippet

$FramesetHelper

Class FramesetHelper

$HelperFactory

Converts the characters <, >, & and " into their corresponding HTML entity.

Snippet

$HelperFactory

Class HelperFactory

$I18N

Object for accessing language constants.

Snippet

$I18N

Class LanguageConstantsCallable

$JSON

Auxiliary functions for creating and working with JSON objects.

Snippet

$JSON

Class JSONUtil

$lang

Current portal language.

Snippet

$lang

$layout

Name of the current layout.

Snippet

$layout

$LayoutManager

Access layout information.

Snippet

$LayoutManager

Class LayoutManagerCallable

$ListBoxControl

Object for accessing drop-down lists.

Snippet

$ListBoxControl

Class VCListBoxControl

$ListFormatter

Auxiliary functions for formatting lists.

Snippet

$ListFormatter

Class ListFormatter

$Loader

Processes incoming requests. You can, for example, access the current database connection via the $Loader.

Snippet

$Loader

Class BuslogicCaller

$Locales

Access regional settings for number and date values.

Snippet

$Locales

Class VCLocales

$LogAnalyzer

Object for generating application, user and statistic reports.

Snippet

$LogAnalyzer

Class LogAnalyzer

$MBGallery

Object for processing and copying/moving/deleting images.

Snippet

$MBGallery

Class Gallery

$Math

Object for diverse arithmetical operations.

Snippet

$Math

Class MathUtil

$Menu

Object for accessing the menu structure.

Snippet

$Menu

Class MenuCallable

$MenuCloud

Object for accessing a menu cloud.

Snippet

$MenuCloud

Class MenuCloud

$ObjectHelper

Object for null objects and ValueHolders.

Snippet

$ObjectHelper

Class ObjectHelper

$PageUtil

Object for accessing controls and data on the view page of a data record.

Snippet

#set($renderer = $RendererFactory.getDefaultRenderingContext($ProcessingContext, $User, $lang))
#set($page = $PageUtil.process($RenderingContext, $ProcessingContext, $Request.get("rq_AppGuid"), $DC))

The rendering and processing context as well as the GUID of the current application and a DataCollection are required for initialization.

Example

$page.getControlNames()
## Sample output
## [textvcontrol60C5B1A8, datetimevcontrol88EFC15D, checkvcontrol68B97F7C, integervcontrolE018B980]

$page.getControlGuids()
## Sample output
## [4A21CF034953825EE93093E0C8E51C959D193C5F, 4B953139D2E394C42BD20919A2C1CA757EC10A1A]

The variable "$page" can be used to access controls and data fields on the page.

Class PageUtil

$Parameter

Object for accessing parameters.

Snippet

$Parameter

Class VCParameter

$PolicyBrowserFactory

Provides access to objects that can be used to read permissions of users, sets or containers.

Snippet

$PolicyBrowserFactory

Class Factory

$PollHelper

Object for requesting poll properties.

Snippet

$PollHelper

Class PollCallable

$Portal

Object for accessing portal properties (e.g. name).

Snippet

$Portal

Class Portal

$Portal - Access the organizational structure

Object for accessing the organizational structure of the portal.

Snippet

$Portal.getOrgStructure()

Class VelocityOrgStructureWrapper

$PreparedQuery

Object for creating and performing database requests.

Snippet

$PreparedQuery

Class DbQuery

$ProcessingContext

Object of the current processing context.

Snippet

$ProcessingContext

Class BusinessLogicProcessingContext

Class BusinessLogicProcessingContext

Object for creating a new xsd:QName namespace.

Snippet

$QNameFactory

Class QNameFactory

$Renderer

Object for creating diverse renderers.

Snippet

$Renderer

Class StandardUtilRendererFactory

$RenderingContext

Object for accessing the current, default portal rendering settings.

Snippet

$RenderingContext

Class RenderingContext

$Request

Object for setting and reading request variables.

Snippet

$Request

Class IServerBridgeRequest

$Response

Object for setting and reading properties of an HTTP response.

Snippet

$Response

Class HttpResponseWrapper

$RtCache

Runtime cache object with information about applications, data groups etc.

Snippet

$RtCache

Class VelocityRtCache

$SaucMenu

Objects for setting menu permissions in the web CMS.

Snippet

$SaucMenu

Class SaucMenuPermission

$SearchUtil

Object for search queries.

Snippet

$SearchUtil

Class SearchUtil

$Session

Access the session of the current user.

Snippet

$Session

Class Session

$SettingsHelper

Object for reading settings.

Snippet

$SettingsHelper

Class VCSettingsHelper

$SharedState

Set and read user-defined values in the processing context. Read a value from the processing context:

Example 1

$SharedState.get("meineVariable")

Write a value to the processing context:

Example 2

$SharedState.putAt("meineVariable", "meinWert")

Snippet

$SharedState.get("<paramName>")
$SharedState.putAt("<paramName>", "<paramValue>")

Class SharedState

$Sort

Auxiliary object for sorting lists.

Snippet

$Sort

Class Sort

$SourcePage

Returns, for example, the GUID, application GUID or RecID of the page that sends parameters.

Snippet

$SourcePage

Class VCSourcePage

$TextUtil

Auxiliary object for different types of string manipulations.

Snippet

$TextUtil

Class TextUtil

$TickerMan

Object for accessing the RSS provider.

Snippet

$TickerMan

Class TickerManager

$Unique

Object for generating unique variables.

Snippet

$Unique

Class Unique

$UrlBuilder

Object for creating URLS. Methods to generate URLs:

  • createBaseUrl

  • createAbsoluteBaseUrl

  • createAbsoluteRequestBaseDirectoryUrl

  • createWebSocketBaseUrl

  • parseUrl

All other methods for generating URLs are deprecated:

  • createDefaultUrl

  • createAbsoluteBaseDirectoryUrl

  • createRequestBaseDirectoryUrl

createBaseUrl

Always creates the relative base URL.

createAbsoluteBaseUrl

Creates the absolute base URL ending with a slash. The base URL configured in the portal is usually used for this purpose.

If no base URL is configured, this URL is constructed from the server variables SCHEME, SERVER_NAME and SERVER_PORT.

createAbsoluteRequestBaseDirectoryUrl

Creates an absolute URL. Its path section is equal to the path from the request URI, without the document section. The document portion is the rightmost path section that is not followed by a slash. The query string is discarded.

Example:

$UrlBuilder.createAbsoluteRequestBaseDirectoryUrl($Request) returns https://example.org/dir1/dir2/ for the request https://example.org/dir1/dir2/foo.vm.

$UrlBuilder.createAbsoluteRequestBaseDirectoryUrl($Request) returns https://example.org/dir1/dir2/ for the request https://example.org/dir1/dir2/.

parseUrl

Parses the specified URL and returns a corresponding URL object.

Snippet

$UrlBuilder

Class UrlBuilder

$User

Object for accessing information of the current user.

Snippet

$User

Class User

$VDiff

Object for displaying diffs of wiki entries.

Snippet

$VDiff

Class VDiff

$VH

Object for creating ValueHolders.

Snippet

$VH

Class ValueHolderFactory

$VHHelper

Auxiliary class for reading values in ValueHolders.

Snippet

$VHHelper

Class VCValueHolderHelper

$VelocityContext

Snippet

$VelocityContext

Class VelocityUtil

$VelocityUtil

Snippet

$VelocityUtil

Class VelocityUtil

$Wiki

Snippet

$Wiki

Class WikiRenderer

$Zebra

The Zebra callable makes it easier to output two alternating character strings.

Example

#set($zebra = $Zebra.createZebra("black", "white"))

$zebra.getStripe()
$zebra.getStripe()
$zebra.getStripe()
$zebra.getStripe()
$zebra.getSameStripe()

returns

black
white
black
white
white

Snippet

$Zebra

Class Zebra

Class ZebraFactory

Databases

Current database connection

Gets the current system connection to the database.

Snippet

$DbConnection

Access an external data connection.

Access an external data connection.

Snippet

$DbUtil.getConnection("connectionName")

Get all column names of a data group

Returns a list of column names from the data group with the stated GUID.

Snippet

#set($fields = $RtCache.getFields())
#set($columnNames = [])

#foreach($field in $fields)
	#if($field.getDataGroupGuid() == "<DG_GUID>")
		#set($bResult = $columnNames.add($field.getColumnName()))
	#end
#end

Prepared statement with SELECT

Executes a SELECT query on a database table.

Snippet

#set($statement = $PreparedQuery.prepare($DbConnection, "SELECT <COLUMNS> FROM DATAGROUP('<DATAGROUP_GUID>') WHERE <CONDITION>"))
##$statement.setString(1, "Example text")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
#set($rs = $statement.executeQuery())
#foreach($element in $rs)
	##$element.getIntValue(1)
	##$element.getStringValue(2)
	##$element.getBooleanValue(3)
	##$element.getTimestampValue(4)
#end
$rs.close()
$statement.close()

Class DbPreparedStatement

Prepared statement with INSERT

Executes an INSERT query on a database table.

Snippet

#set($conn = $DbConnection)
#set($statement = $PreparedQuery.prepare($conn, "INSERT INTO DATAGROUP('<DATAGROUP_GUID>') (<COLUMNS>) VALUES ()"))
$DbUtil.transactionEnlistResource($conn)
##$statement.setString(1, "Example text")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
##$statement.setTimestamp(4, $DtUtil.utcNow())
$statement.executeUpdate()
$statement.close()

Class DbPreparedStatement

Prepared statement with UPDATE

Executes an UPDATE query on a database table.

Snippet

#set($l_conn = $DbConnection)
#set($statement = $PreparedQuery.prepare($l_conn, "UPDATE DATAGROUP('<DATAGROUP_GUID>') SET <COLUMN> = ? WHERE <CONDITION>"))
$DbUtil.transactionEnlistResource($l_conn)
##$statement.setString(1, "strValue")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
##$statement.setTimestamp(4, $DtUtil.utcNow())
$statement.executeUpdate()
$statement.close()

Class DbPreparedStatement

Prepared statement with DELETE

Executes an DELETE query on a database table.

Snippet

#set($conn = $DbConnection)
#set($statement = $PreparedQuery.prepare($conn, "DELETE FROM DATAGROUP('<DATAGROUP_GUID>') WHERE <CONDITION>"))
$DbUtil.transactionEnlistResource($conn)
##$statement.setString(1, "Example text")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
##$statement.setTimestamp(4, $DtUtil.utcNow())
$statement.executeUpdate()
$statement.close()

Class DbPreparedStatement

Read a single value using a prepared database query (with fallback)

Reads a single value from a database query. If the result set is empty, or the value is null, the fallbackValue is returned. If the return data type should be defined more precisely, typed method calls such as executeAndGetScalarBooleanValue(...) can be used.

Snippet

#set($statement = $PreparedQuery.prepare($DbConnection, "SELECT <COLUMN> FROM DATAGROUP('<DATAGROUP_GUID>') WHERE <CONDITION>"))
##$statement.setString(1, "Example text")
##$statement.setInt(2, 123)
##$statement.setBoolean(3, true)
#set($result = $statement.executeAndGetScalarValue(<FALLBACK_VALUE>))
$statement.close()

Class DbPreparedStatement

Determine the database type

Gets the database type of the system connection. Compare the database type with following identifiers:

  • Generic descriptor: $strType.contains("Standard")

  • PostgreSQL: $strType.contains("PostgreSQL")

  • Oracle allgemein, Oracle10, Oracle11:
    $strType.contains("Oracle")
    $strType.contains("Oracle10")
    $strType.contains("Oracle11")

  • DB2: $strType.contains("Db2")

  • Derby: $strType.contains("Derby")

  • MsSqlServer: $strType.contains("MsSqlServer")

Unsupported system databases:

  • AbacusPervasive: $strType.contains("AbacusPervasive")

  • Firebird: $strType.contains("Firebird")

  • HSQLDB: $strType.contains("HSQLDB")

  • Ingres: $strType.contains("Ingres")

  • MaxDB/ SAP DB: $strType.contains("MaxDB")

  • Oracle 8, Oracle 9:
    $strType.contains("Oracle8")
    $strType.contains("Oracle9")

  • solidDB: $strType.contains("soliddb")

Snippet

#set($strType = $DbConnection.getDescriptor().getDatabaseType())

#if($strType.contains("<DATABASE_IDENTIFIER>"))
#end

Class DbPreparedStatement

Timestamp for system values

This variable contains the timestamp of the current transaction and remains unmodified until the end of this transaction.

Snippet

$CURRENT_TIMESTAMP

Debugging

Inspect an object

Inspects an object.

Snippet

$DEBUG.inspect()

Class ObjectInspector

Write info to log file

Writes an INFO entry to the log file that belongs to the execution context of the script.

Snippet

$DEBUG.info()

Class ObjectInspector

Write warning to log file

Writes a WARN entry to the log file that belongs to the execution context of the script.

Snippet

$DEBUG.warn()

Class ObjectInspector

Write error to log file

Writes an ERROR entry to the log file that belongs to the execution context of the script.

Snippet

$DEBUG.error()

Class ObjectInspector

Stopwatch - Start

Starts the stopwatch.

Snippet

${DEBUG.builtinStopwatch.start()}

Class ObjectInspector

Stopwatch - Take split time

Takes the split time of the stopwatch.

Snippet

${DEBUG.builtinStopwatch.stop()}

Class ObjectInspector

Stopwatch - Restart

Restarts the stopwatch.

Snippet

${DEBUG.builtinStopwatch.restart()}

Class ObjectInspector

Portal data

Portal name

Returns the name of the current portal as a string.

Snippet

$Portal.getPortalName()

Class Portal

Time zone

Gets the portal's default time zone.

Snippet

$Portal.getTimeZone()

Class Portal

Users online

Returns a list of GUIDs of all logged-in users of the current portal. The parameter true/false defines whether anonymous users are included in the result list.

Example

also returns anonymous users

$Portal.getUsersOnline(true)

Snippet

$Portal.getUsersOnline(bIncludeAnonymousUsers)

Class Portal

Active sessions

Gets the number of active portal sessions.

Snippet

$Portal.getActiveSessionCount()

Class Portal

Calculate

Add

Adds two integer, float or double values.

Snippet

$Math.add($value1, $value2)

Class MathUtil

Subtract

Subtracts two integer, float or double values.

Snippet

$Math.sub($value1, $value2)

Class MathUtil

Multiply

Multiplies two integer, float or double values.

Snippet

$Math.mult($value1, $value2)

Class MathUtil

Divide

Divides two double values.

Snippet

$Math.div($value1, $value2)

Class MathUtil

Maximum

Calculates the maximum of two values.

Snippet

$Math.max($value1, $value2)

Class MathUtil

Minimum

Calculates the minimum of two values.

Snippet

$Math.min($value1, $value2)

Class MathUtil

Renderer

Current date

Creates and formats a date according to the specified portal settings.

Snippet

$DefaultDateTimeRenderer.writeOutput($Response.getWriter(), $DtUtil.now($User.getTimeZone()))

Current date in user-defined format

Creates and formats a date according to a user-defined renderer. Output in this example (last value denotes the calendar week): 21.09.2009 12:14:35 39

Snippet

#set($dateTimeRenderer = $RendererFactory.createDateTimeRendererWithParameters($RenderingContext, false, false, null, "dd.MM.yyyy HH.mm.ss CW", "", null))
$dateTimeRenderer.writeOutput($Response.getWriter(), $DtUtil.now($User.getTimeZone()))

Rendering context

Access the current rendering context.

Snippet

$RenderingContext

Class RenderingContext

Date

Localize date

Creates and formats a date according to the specified location. The specified location needs to be defined as a portal language in the portal properties.

Snippet

$DtUtil.now($User.getTimeZone()).format($Locales.getLocale("en-US").getDateFormat())

Session

Session ID

Returns the ID of the current session.

Snippet

$Session.getId()

Class Session

Read session variable

Writes a session variable.

Snippet

$Session.get(strSessionVar)

Class Session

Write session variable

Writes a session variable.

Snippet

$Session.put(strSessionVar, strValue)

Class Session

Escaping

$ Dollar sign

Escape for dollar sign.

Snippet

${ESC.D}

Class EscapedCharacters

# Number sign; hash

Escape for hash sign.

Snippet

${ESC.H}

Class EscapedCharacters

" Quotation mark

Escape for quotation mark.

Snippet

${ESC.QUOT}

Class EscapedCharacters

! Exclamation mark

Escape for exclamation mark.

Snippet

${ESC.EXCL}

Class EscapedCharacters

\ Backslash

Escape for backslash

Snippet

${ESC.BSL}

Class EscapedCharacters

CR Carriage return

Escape for CR carriage return.

Snippet

${ESC.CR}

Class EscapedCharacters

LF Line feed

Escape for LF line feed.

Snippet

${ESC.CR}

Class EscapedCharacters

CRLF Line break

Escape for CRLF line break.

Snippet

${ESC.CR}

Class EscapedCharacters

TAB horizontal tabulation

Escape for TAB horizontal tabulation.

Snippet

${ESC.TAB}

Class EscapedCharacters

TextUtil

Convert an array into a string

Converts an array list into a string, using the default delimiter | and escape character 0. To use different delimiter and escape characters, call the function with additional parameters.

Example

//Uses default separator and escape characters.
$TextUtil.arrayToString(p_array)
//Userdefined separator and escape characters.
$TextUtil.arrayToString(p_array, "$", "!")

Snippet

$TextUtil.arrayToString()

Class TextUtil

Convert a string into an array

Converts a string into an array, if the string was previously created using arrayToString(p_myArray) with default delimiter (|) and escape character (0).

Example

$TextUtil.stringToArray(p_string)

Snippet

$TextUtil.stringToArray()

Class TextUtil

Split a string

Splits a string to an array using the stated separator.

Example

$TextUtil.split(p_string, "$")

Snippet

$TextUtil.split(p_string, p_delimiter)

Class TextUtil

Parse an integer string

Parses an integer string to an integer.

Example

$TextUtil.parseInt("1234")

Snippet

$TextUtil.parseInt()

Class TextUtil

Parse a double string

Parses a double string to a double.

Example

$TextUtil.parseDouble("1234.56")

Snippet

$TextUtil.parseDouble()

Class TextUtil

ValueHolder

Create a ValueHolder

Creates a ValueHolder from the given object.

Snippet

$VH.getValueHolder($object)

Class ValueHolderFactory

Create a ValueHolder with the current date

Creates a ValueHolder with the current date.

Snippet

$VH.getNowValueHolder()

Class ValueHolderFactory

Versioning

Display semantic version information of an application

Example

#set ($version = $Portal.getApplicationVersionInformation("8D3B7A6462649864241A4534FD48364AF378218A").getCurrentVersion())
$version.getFormattedVersion()
$version.getDescriptions().get("de")
$version.getMajorVersion()
$version.getMinorVersion()
$version.getPatchVersion()
$version.getPreReleaseVersion()
$version.getCustomVersion()
$version.getDate()
$version.getMinProductVersion()
$version.getAdditionalRequirements().get("de")

Snippet

$Portal.getApplicationVersionInformation("")

Class Portal

Display semantic version information of a process

Example

#set ($version = $Portal.getWorkflowVersionInformation("B239068CECAA616964F71825C2CB9DB74DBB1BBA").getCurrentVersion())
$version.getFormattedVersion()
$version.getDescriptions().get("de")
$version.getMajorVersion()
$version.getMinorVersion()
$version.getPatchVersion()
$version.getPreReleaseVersion()
$version.getCustomVersion()
$version.getDate()
$version.getMinProductVersion()
$version.getAdditionalRequirements().get("de")

Snippet

$Portal.getWorkflowVersionInformation("")

Class Portal

Display semantic version information of a layout

Example

#set ($version = $Portal.getLayoutVersionInformation("Beispiellayout").getCurrentVersion())
$version.getFormattedVersion()
$version.getDescriptions().get("de")
$version.getMajorVersion()
$version.getMinorVersion()
$version.getPatchVersion()
$version.getPreReleaseVersion()
$version.getCustomVersion()
$version.getDate()
$version.getMinProductVersion()
$version.getAdditionalRequirements().get("de")

Snippet

$Portal.getLayoutVersionInformation("")

Class Portal

Connector for Microsoft Exchange

Current Exchange connection

Returns information about an Exchange folder (the inbox folder in this example)

Snippet

#set($conn = $ExchangeConnectionCallable.getConnection())

Class ExchangeConnectionCallable

Folder information

Returns information about an Exchange folder (the inbox folder in this example)

Snippet

#set($inbox = $ExchangeMailboxCallable.getInboxFolderHref($strMailboxName))
$ExchangeMailboxCallable.getFolderInfoByHref($inbox)

Class ExchangeMailboxCallable

Mailbox name of the current Exchange user

Returns the mailbox name of the current Exchange user.

Snippet

#set($strMailboxName = $ExchangeUserMailboxCallable.getMailboxInfo().getMailboxName())

Class ExchangeUserMailboxInfo

Account of the current Exchange user

Returns the account connected to the current Exchange connection.

Snippet

#set($account = $ExchangeUserMailboxCallable.getMailboxInfo().getUserAccount())

Class ExchangeAccount

Set the out of office message

Writes the out of office message and sets its status to active. The text is set for internal and external out of office messages.

Snippet

#set($strMessage = "Out of office till 2010/12/31")
$ExchangeMailboxCallable.setOutOfOfficeMessage($strMessage)
$ExchangeMailboxCallable.setOutOfOffice(true) 

Class ExchangeMailboxCallable

Mark a messsage as read

Marks the message with the stated ID as read. Example (on an email view page)

Snippet

$ExchangeMessageCallable.setMessageRead($messageId)

Class ExchangeMessageCallable

Message attachments

Returns the attachments of the mail with the stated ID. Example (on an email view page):$ExchangeItemCallable.getAttachments($DC.getRecId())

Snippet

$ExchangeItemCallable.getAttachments($messageId)

Class ExchangeItemCallable

Create an Exchange appointment

Creates an appointment for the current user.

Parameters:
$startDate - Start date of the appointment
$endDate - End date of the appointment
$subject - Subject of the appointment
$body - Description of the appointment

If additional properties are set or updated with set()-methods after creating the appointment, they have to be saved with $appointment.save() afterwards.

Example

#set($appointment = $ExchangeAppointmentCallable.createNewAppointment($startDate, $endDate, $subject, $body))

$appointment.setLocation("Konferenzraum")
$appointment.save()

Snippet

#set($appointment = $ExchangeAppointmentCallable.createNewAppointment($startDate, $endDate, $subject, $body))

Class ExchangeAppointmentCallable

Create an Exchange contact

Creates a new contact for the current user.

Parameters:
$lastName - Last name of the contact
$firstName - First name of the contact
$mail - Email address of the contact
$mailbox - The user's mailbox that the contact should be added to. If null, the current user's mailbox is used.

If additional properties are set or updated with set()-methods after creating the contact, they have to be saved with $contact.save() afterwards.

Example

#set($contact = $ExchangeContactCallable.createNewContact($lastName, $firstName, $mail, $mailbox))

$contact.setJobTitle("Developer")
$contact.save()

Snippet

#set($contact = $ExchangeContactCallable.createNewContact($lastName, $firstName, $mail, $mailbox))

Class ExchangeContactCallable

Create and end Exchange email

Creates a new email for the current Exchange user.

Parameters:
$from - Sender address
$to - Recipient address
$subject - Subject text
$body - Message text

onal properties are set or updated with set()-methods after creating the message, they have to be saved with $message.save() afterwards.

Example

#set($message = $ExchangeMessageCallable.createNewDraft(strSender, strRecipient, strSubject, strBody))
$message.setCc("cc_recipient@example.org")
$message.save()

$message.send()

Snippet

#set($message = $ExchangeMessageCallable.createNewDraft(strSender, strRecipient, strSubject, strBody))

Class ExchangeMessageCallable

Create an Exchange note

Creates a note for the current user.

Parameters:
$text - Text of the note
$mailbox - The user's mailbox that the note should be added to. If null, the current user's mailbox is used.

Example

#set($note = $ExchangeNoteCallable.createNewNote("My note", null))

Snippet

#set($note = ExchangeNoteCallable.createNewNote($text, $mailbox))

Class ExchangeNoteCallable

Create an Exchange task

Creates a task for the current user.

Parameters:
$start - The tasks start date
$due - The tasks due date
$subject - The tasks subject
$mailbox - The user's mailbox that the task should be added to. If null, the current user's mailbox is used.

Example

#set($task = $ExchangeTaskCallable.createNewTask(${cursor}dtStart, dtDue, "Task subject", null))

$task.setPercentComplete(25.0)
$task.save()

Snippet

#set($task = $ExchangeTaskCallable.createNewTask(dtStart, dtDue, "Task subject", null))

Class ExchangeTaskCallable

If Else

Basic framework for an "if else" condition.

Snippet

#if(condition1)
	##code for condition1
#elseif(condition2)
	##code for condition2
#else
	##code if no condition matches
#end

Velocity overview

For each loop

foreach loop code snippet.

Snippet

#foreach($element in )
	
#end

Velocity overview

Define a variable

Example

#set( $id = 1)
#set( $userName = "Administrator")

Snippet

#set($variable = aValue)

Velocity overview

Output variable in local format

Outputs a variable in the portal's local format. The variable has to be defined in a ValueHolder. The following types can be used as the RENDERING_TYPE: integer, datetime, date, time, currency, number, boolean, author.

Example

#set($vhValue = $VH.getValueHolder(1))
#writeVH($vhValue, "currency", true, false, false)

Snippet

#set($vhValue = $VH.getValueHolder($object))
#writeVH($vhValue, "<RENDERING_TYPE>", true, false, false)

Velocity overview

Read request parameter

Read a request parameter

Snippet

$!Request.get("rq_param")

Class IServerBridgeRequest

Write request parameter

Write a request parameter

Snippet

$Request.put("rq_param", "strValue")

Class IServerBridgeRequest

All data groups of an application

Returns the names of all data groups of the application with the stated GUID.

Snippet

#set($datagroups = $RtCache.getDataGroups($RtCache.filter.dataGroup.getByApplication(<GUID-der-Applikation>)))
#foreach($datagroup in $datagroups)
	Name: $datagroup.getName()
#end

Class VelocityRtCache

Dynamic identification of a table name per sysident

To identify the table name via sysident, the expert attribute "sysident" has to be defined on the "Expert" tab of the data group properties. The sysident value is case-sensitive.

Example

$RtCache.getFirstDataGroup($RtCache.filter.dataGroup.getBySysIdent("4B73F01B5F97199C578431966703239ED1AD8397", "mein-sysident")).getTableName()

Snippet

$RtCache.getFirstDataGroup($RtCache.filter.dataGroup.getBySysIdent("<GUID-der-Applikation>", "<Sysident-Wert>)).getTableName()

Class VelocityRtCache

Current date with the current user's time zone

Creates a current date considering the time zone of the current user.

Snippet

$DtUtil.now($User.getTimeZone())

Class CalendarAwareDate

Create a JSON response

Creates a JSON response

Snippet

## This is necessary: Prevent the response from linebreaks, unwanted outputs, etc.
$Response.setIgnoreWrite(true)

## in here you can write your Velocity-Code without effecting the response accidentally
## e.g. set a variable
#set($myVar = "Hello client!")

## This may help you: Using a java.util.Map to go on easy with JSON-formatting later.
#set($map = $CollectionFactory.createMap())
## Add everything you need into the map with a reliable key.
$map.put("myJSONAnswer", $myVar)

## This is necessary: Format the response, so the server delivers JSON.
$Response.setHeader("Cache-Control", "no-cache")
$Response.setHeader("Content-Type", "application/json;charset=UTF-8")

## Format the Map to be escaped for the JSON-String.
$Response.setIgnoreWrite(false)$JSON.toJSONString($map)

Class JSONUtil

Create a GUID

Generates a new GUID.

Snippet

$Unique.newGuid()

Class Unique