org.opencms.jsp.util
Class CmsJspElFunctions

java.lang.Object
  extended by org.opencms.jsp.util.CmsJspElFunctions

public final class CmsJspElFunctions
extends Object

Provides utility methods to be used as functions from a JSP with the EL.

Since:
7.0.2
See Also:
CmsJspContentAccessBean

Method Summary
static CmsObject convertCmsObject(Object input)
          Returns an OpenCms user context created from an Object.
static Date convertDate(Object input)
          Returns a Date created from an Object.
static List<Object> convertList(List<Object> input, String attributeName)
          Returns a list of attribute values specified by the attribute name of the items of the given list.
static Locale convertLocale(Object input)
          Returns a Locale created from an Object.
static javax.servlet.ServletRequest convertRequest(Object input)
          Tries to convert the given input object into a request.
static CmsResource convertResource(CmsObject cms, Object input)
          Returns a resource created from an Object.
static CmsUUID convertUUID(Object input)
          Returns a CmsUUID created from an Object.
static String escape(String source, String encoding)
          Encodes a String in a way that is compatible with the JavaScript escape function.
static CmsObject getCmsObject(Object input)
          Returns the current OpenCms user context from the given page context.
static Integer getListSize(List<Object> input)
          Returns the size of the given list.
static String getNavigationUri(Object input)
          Returns the current navigation URI.
static String getRequestLink(String url)
          Returns the link without parameters from a String that is formatted for a GET request.
static String getRequestParam(String url, String paramName)
          Returns the value of a parameter from a String that is formatted for a GET request.
static CmsJspVfsAccessBean getVfsAccessBean(Object input)
          Returns a JSP / EL VFS access bean.
static String stripHtml(Object input)
          Strips all HTML markup from the given input.
static String trimToSize(String input, int length)
          Returns a substring of the source, which is at most length characters long.
static String unescape(String source, String encoding)
          Decodes a String in a way that is compatible with the JavaScript unescape function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertCmsObject

public static CmsObject convertCmsObject(Object input)
Returns an OpenCms user context created from an Object.

Parameters:
input - the input to create an OpenCms user context from
Returns:
an OpenCms user context created from an Object

convertDate

public static Date convertDate(Object input)
Returns a Date created from an Object.

Parameters:
input - the Object to create a Date from
Returns:
a Date created from the given Object

convertList

public static List<Object> convertList(List<Object> input,
                                       String attributeName)
Returns a list of attribute values specified by the attribute name of the items of the given list.

Parameters:
input - the list of objects to obtain the attribute values from
attributeName - the name of the attribute to obtain
Returns:
a list of attributes specified by the attribute name of the items of the given list

convertLocale

public static Locale convertLocale(Object input)
Returns a Locale created from an Object.

Parameters:
input - the Object to create a Locale from
Returns:
a Locale created from the given Object

convertRequest

public static javax.servlet.ServletRequest convertRequest(Object input)
Tries to convert the given input object into a request.

This is only possible if the input object is already a request or if it is a page context.

If everything else, this method returns null.

Parameters:
input - the input object to convert to a request
Returns:
a request object, or null

convertResource

public static CmsResource convertResource(CmsObject cms,
                                          Object input)
                                   throws CmsException
Returns a resource created from an Object.

Parameters:
cms - the current OpenCms user context
input - the input to create a resource from
Returns:
a resource created from the given Object
Throws:
CmsException - in case of errors accessing the OpenCms VFS for reading the resource

convertUUID

public static CmsUUID convertUUID(Object input)
Returns a CmsUUID created from an Object.

Parameters:
input - the Object to create a CmsUUID from
Returns:
a CmsUUID created from the given Object

escape

public static String escape(String source,
                            String encoding)
Encodes a String in a way that is compatible with the JavaScript escape function.

Parameters:
source - The text to be encoded
encoding - the encoding type
Returns:
The JavaScript escaped string

getCmsObject

public static CmsObject getCmsObject(Object input)
Returns the current OpenCms user context from the given page context.

Parameters:
input - the input to create a CmsObject from
Returns:
the current OpenCms user context from the given page context

getListSize

public static Integer getListSize(List<Object> input)
Returns the size of the given list.

Parameters:
input - the list of objects to obtain the size from
Returns:
the size of the given list

getNavigationUri

public static String getNavigationUri(Object input)
Returns the current navigation URI.

Which can be the request URI or the VFS resource URI.

In case a sitemap is used, the navigation URI will be the request URI, if not the VFS resource URI is returned.

Parameters:
input - the request convertible object to get the navigation URI from
Returns:
the current navigation URI

getRequestLink

public static String getRequestLink(String url)
Returns the link without parameters from a String that is formatted for a GET request.

Parameters:
url - the URL to remove the parameters from
Returns:
the link without parameters

getRequestParam

public static String getRequestParam(String url,
                                     String paramName)
Returns the value of a parameter from a String that is formatted for a GET request.

Parameters:
url - the URL to get the parameter value from
paramName - the request parameter name
Returns:
the value of the parameter

getVfsAccessBean

public static CmsJspVfsAccessBean getVfsAccessBean(Object input)
Returns a JSP / EL VFS access bean.

Parameters:
input - the Object to create a CmsObject from
Returns:
a JSP / EL VFS access bean

stripHtml

public static String stripHtml(Object input)
Strips all HTML markup from the given input.

Parameters:
input - the input to Strip from HTML
Returns:
the given input with all HTML stripped.

trimToSize

public static String trimToSize(String input,
                                int length)
Returns a substring of the source, which is at most length characters long.

If a char is cut, " ..." is appended to the result.

Parameters:
input - the string to trim
length - the maximum length of the string to be returned
Returns:
a substring of the source, which is at most length characters long
See Also:
CmsStringUtil.trimToSize(String, int, String)

unescape

public static String unescape(String source,
                              String encoding)
Decodes a String in a way that is compatible with the JavaScript unescape function.

Parameters:
source - The String to be decoded
encoding - the encoding type
Returns:
The JavaScript unescaped String