SPTools Function Library
Immediately before any template is submitted for evaluation by the Velocity engine, the spTools
argument is added to the VelocityContext so the template can access its methods. SPTools is a function library that contains a few localization utility methods to help with message formatting – primarily date formatting. The methods available within spTools
are listed below:
String formatDate(Object date)
Formats the passed-in date object to a string representation using the IIQ default date and time styles (both the java.util.dateformat SHORT formats), formatted per the norms of the server's default locale and timezone
String formatDate(Object date, Integer dateStyle, Integer timeStyle)
Formats the passed-in date object to a string representation using the specified date and time styles, formatted per the norms of the server's default locale and timezone
NOTE: The styles are represented by constant values:
SHORT = 3
MEDIUM = 2
LONG = 1
FULL = 0
dateStyle and timeStyle correspond to java.text.DateFormat constants. See the Sun Javadocs for details
String formatDate(Object date, String formatString)
Formats the date according to the specified formatString (uses the java.text.SimpleDateFormat method)
String getMessage(String key)
Returns an internationalized message from the message catalog corresponding to the provided key
String escapeHtml(String string)
Converts HTML special characters to their entity equivalents
Example:escapeHtml('<div class="article">This is an article</div>')
Returns: <div class="article">This is an article</div>
String formatURL(String)
Reformats a URL to a format that can be used in contexts external to IdentityIQ such as an email. This is necessary since not all browsers will re-apply the fragment identifier (named anchor portion of the URL) after getting redirected though the login process.
For example, it can reformat
/ui/index.jsf#/myApprovals
to
<serverRootPath>/ui/rest/redirect?rp1=/ui/index.jsf&rp2=myApprovals
It also handles query parameters, for example reformatting
/ui/index.jsf?a=foo&b=bar#/myApprovals
to
<serverRootPath>/ui/rest/redirect?a=foo&b=bar&rp1=/ui/index.jsf&rp2=myApprovals
All URLs within emails should go through this reformat.
The <serverRootPath>
added to the URL is contained in the serverRootPath entry in the SystemConfiguration object.
In the out-of-the-box email templates, the most commonly used method from this library is the formatDate()
method that takes a date object and two integers as arguments:
$spTools.formatDate($expiration,3,1)
After the reference shown above is resolved by Velocity, the date/time value in the expiration argument is printed in the email message in MM/dd/yy hh:mm:ssPM format (or the appropriate equivalent for the server's locale).