nu.staldal.lsp.servlet
Class XSLTExt

java.lang.Object
  extended by nu.staldal.lsp.servlet.XSLTExt

public class XSLTExt
extends java.lang.Object

Access LSP functions from XSLT stylesheets.


Method Summary
static java.lang.String encodeURL(java.lang.Object context, java.lang.String url)
          Encode an URL for Servlet session tracking.
static java.lang.String formatCustomDateTime(java.lang.Object context, java.lang.String pattern, java.util.Date date)
          Format a java.util.Date as String using the user's locale with custom format.
static java.lang.String formatDate(java.lang.Object context, java.util.Date date)
          Format a java.util.Date as String using the user's locale.
static java.lang.String formatDateTime(java.lang.Object context, java.util.Date date)
          Format a java.util.Date as String using the user's locale.
static java.lang.String formatTime(java.lang.Object context, java.util.Date date)
          Format a java.util.Date as String using the user's locale.
static boolean isUserInRole(java.lang.Object context, java.lang.String role)
          Check if user is in role.
static java.lang.String lang(java.lang.Object context, java.lang.String key)
          Get a localized resource for the user's locale.
static java.lang.String lang(java.lang.Object context, java.lang.String pageName, java.lang.String key)
          Get a localized resource for the user's locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

lang

public static java.lang.String lang(java.lang.Object context,
                                    java.lang.String pageName,
                                    java.lang.String key)
                             throws java.lang.Exception
Get a localized resource for the user's locale.

Parameters:
context - the LSPServletContext
pageName - LSP page name, or null for global resources only
key - the key
Returns:
[key] if not found.
Throws:
java.lang.Exception - if the LocaleBundleFactory throws any exception

lang

public static java.lang.String lang(java.lang.Object context,
                                    java.lang.String key)
                             throws java.lang.Exception
Get a localized resource for the user's locale.

Same as lang(context,null,key).

Parameters:
context - the LSPServletContext
key - the key
Returns:
[key] if not found.
Throws:
java.lang.Exception - if the LocaleBundleFactory throws any exception

encodeURL

public static java.lang.String encodeURL(java.lang.Object context,
                                         java.lang.String url)
Encode an URL for Servlet session tracking.

Parameters:
context - the LSPServletContext
url - the URL to encode
Returns:
the encoded URL
See Also:
HttpServletResponse.encodeURL(java.lang.String)

isUserInRole

public static boolean isUserInRole(java.lang.Object context,
                                   java.lang.String role)
Check if user is in role.

Parameters:
context - the LSPServletContext
role - the role to check
Returns:
true if user is in the given role
See Also:
HttpServletRequest.isUserInRole(String)

formatDate

public static java.lang.String formatDate(java.lang.Object context,
                                          java.util.Date date)
Format a java.util.Date as String using the user's locale.

Parameters:
context - the LSPServletContext
date - the date to format
Returns:
the formatted date

formatTime

public static java.lang.String formatTime(java.lang.Object context,
                                          java.util.Date date)
Format a java.util.Date as String using the user's locale.

Parameters:
context - the LSPServletContext
date - the time to format
Returns:
the formatted time

formatDateTime

public static java.lang.String formatDateTime(java.lang.Object context,
                                              java.util.Date date)
Format a java.util.Date as String using the user's locale.

Parameters:
context - the LSPServletContext
date - the date/time to format
Returns:
the formatted date/time

formatCustomDateTime

public static java.lang.String formatCustomDateTime(java.lang.Object context,
                                                    java.lang.String pattern,
                                                    java.util.Date date)
Format a java.util.Date as String using the user's locale with custom format.

Parameters:
context - the LSPServletContext
pattern - the formatting pattern
date - the date/time to format
Returns:
the formatted date/time