Class CmsJspElFunctions
- Since:
- 7.0.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Extends the given list by adding the provided object.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 Double
convertDouble
(Object input) Returns a Double created from an 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 CmsResource
convertRawResource
(CmsObject cms, Object input) Returns a resource created from an Object.static javax.servlet.ServletRequest
convertRequest
(Object input) Tries to convert the given input object into a request.static CmsJspResourceWrapper
convertResource
(CmsObject cms, Object input) Returns a resource wrapper created from the input.static List<CmsJspResourceWrapper>
convertResourceList
(CmsObject cms, List<CmsResource> list) Returns a list of resource wrappers created from the input list of resources.static CmsUUID
convertUUID
(Object input) Returns a CmsUUID created from an Object.Returns a newly created, empty List object.static CmsObject
getCmsObject
(Object input) Returns the current OpenCms user context from the given page context.static Integer
getListSize
(Collection<Object> input) Returns the size of the given list.static String
getModuleParam
(String name, String key) Returns a parameter value from the module parameters.static String
getNavigationUri
(Object input) Deprecated.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 boolean
isSubSitemap
(CmsResource resource) Returns whether the given resource is a sub sitemap folder.static boolean
Returns whether the given value is an instance ofA_CmsJspValueWrapper
.static String
jsonGetString
(Object maybeJsonString, Object key) Parses the JSON String and returns the requested value.Converts a string (which is assumed to contain a JSON object whose values are strings only) to a map, for use in JSPs.static String
Looks up the given key from the map that is passed as a String, and returns either the element found or the empty String.static String
Looks up the given key from the map that is passed as a String, and returns either the element found or the default value.static Long
Calculates the next largest integer for the given number parameter.static Long
Calculates the next smallest integer for the given number parameter.static Long
Calculates the next integer for the given number parameter by rounding.static Object
Parses JSON object.static String
repairHtml
(String input) Repairs the given HTML input by adding potentially missing closing tags.static String
Strips all HTML markup from the given input.static Double
Converts the given Object to a (Double) number, falling back to a default if this is not possible.static String
trimToSize
(String input, int length) Returns a substring of the source, which is at most length characters long.static boolean
validateRegex
(String value, String regex) Validates a value against a regular expression.
-
Method Details
-
addToList
Extends the given list by adding the provided object.- Parameters:
list
- the list to extendvalue
- the value to add to the list
-
convertCmsObject
Returns an OpenCms user context created from an Object.- If the input is already a
CmsObject
, it is casted and returned unchanged. - If the input is a
ServletRequest
, the OpenCms user context is read from the request context. - If the input is a
PageContext
, the OpenCms user context is read from the request of the page context. - Otherwise the input is converted to a String which should be a user name, and creation of a OpenCms user context with this name is attempted. Please note that this will only work if the user name is either the "Guest" user or the "Export" user.
- If no valid OpenCms user context could be created with all of the above, then a new user context for the "Guest" user is created.
- Parameters:
input
- the input to create an OpenCms user context from- Returns:
- an OpenCms user context created from an Object
- If the input is already a
-
convertDate
Returns a Date created from an Object.- The Object is first checked if it is a
Date
already, if so it is casted and returned unchanged. - If not, the input is checked if it is a
Long
, and if so the Date is created from the Long value. - If it's not a Date and not a Long, the Object is transformed to a String and then it's tried to parse a Long out of the String.
- If this fails, it is tried to parse as a Date using the default date formatting.
- If this also fails, a new Date is returned that has been initialized with 0.
- Parameters:
input
- the Object to create a Date from- Returns:
- a Date created from the given Object
- The Object is first checked if it is a
-
convertDouble
Returns a Double created from an Object.- If the input already is a
Number
, this number is returned as Double. - If the input is of type
A_CmsJspValueWrapper
, the wrapper is converted to a Double usingA_CmsJspValueWrapper.getToDouble()
. - If the input is a String, it is converted to a Double.
- Otherwise
null
is returned.
- Parameters:
input
- the Object to create a Double from- Returns:
- a Double created from the given Object
- If the input already is a
-
convertList
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 fromattributeName
- 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
Returns a Locale created from an Object.- The Object is first checked if it is a
Locale
already, if so it is casted and returned. - If not, the input is transformed to a String and then a Locale lookup with this String is done.
- If the locale lookup fails, the OpenCms default locale is returned.
- Parameters:
input
- the Object to create a Locale from- Returns:
- a Locale created from the given Object
- The Object is first checked if it is a
-
convertRawResource
Returns a resource created from an Object.- If the input is already a
CmsResource
, it is casted to the resource and returned unchanged. - If the input is a String, the given OpenCms context is used to read a resource with this name from the VFS.
- If the input is a
CmsUUID
, the given OpenCms context is used to read a resource with this UUID from the VFS. - Otherwise the input is converted to a String, and then the given OpenCms context is used to read a resource with this name from the VFS.
- Parameters:
cms
- the current OpenCms user contextinput
- 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
- If the input is already a
-
convertRequest
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 CmsJspResourceWrapper convertResource(CmsObject cms, Object input) throws CmsException Returns a resource wrapper created from the input. The wrapped result ofconvertRawResource(CmsObject, Object)
is returned.- Parameters:
cms
- the current OpenCms user contextinput
- the input to create a resource from- Returns:
- a resource wrapper created from the given Object
- Throws:
CmsException
- in case of errors accessing the OpenCms VFS for reading the resource
-
convertResourceList
public static List<CmsJspResourceWrapper> convertResourceList(CmsObject cms, List<CmsResource> list) Returns a list of resource wrappers created from the input list of resources.- Parameters:
cms
- the current OpenCms user contextlist
- the list to create the resource wrapper list from- Returns:
- the list of wrapped resources.
-
convertUUID
Returns a CmsUUID created from an Object.- Parameters:
input
- the Object to create a CmsUUID from- Returns:
- a CmsUUID created from the given Object
-
createList
Returns a newly created, empty List object.There is no way to create an empty list using standard JSTL methods, hence this function.
- Returns:
- a newly created, empty List object
-
getCmsObject
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
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
-
getModuleParam
Returns a parameter value from the module parameters.- Parameters:
name
- the name of the modulekey
- the parameter to return the value for- Returns:
- the parameter value from the module parameters, or
null
if the parameter is not set
-
getRequestLink
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
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 fromparamName
- the request parameter name- Returns:
- the value of the parameter
-
getVfsAccessBean
Returns a JSP / EL VFS access bean.- Parameters:
input
- the Object to create a CmsObject from- Returns:
- a JSP / EL VFS access bean
-
isSubSitemap
Returns whether the given resource is a sub sitemap folder.- Parameters:
resource
- the resource to check- Returns:
true
if the given resource is a sub sitemap folder
-
isWrapper
Returns whether the given value is an instance ofA_CmsJspValueWrapper
.- Parameters:
value
- the value object to check- Returns:
true
if the given value is an instance ofA_CmsJspValueWrapper
-
jsonGetString
Parses the JSON String and returns the requested value.- Parameters:
maybeJsonString
- the JSON stringkey
- the key- Returns:
- the json value string
-
jsonToMap
Converts a string (which is assumed to contain a JSON object whose values are strings only) to a map, for use in JSPs.If the input can't be interpreted as JSON, an empty map is returned.
- Parameters:
jsonString
- the JSON string- Returns:
- the map with the keys/values from the JSON
-
lookup
Looks up the given key from the map that is passed as a String, and returns either the element found or the empty String.The map String must have the form
"key1:value1|key2:value2"
etc.- Parameters:
key
- the key to look upmap
- the map represented as a String- Returns:
- the element found in the map with the given key, or the empty String
-
lookup
Looks up the given key from the map that is passed as a String, and returns either the element found or the default value.The map String must have the form
"key1:value1|key2:value2"
etc.- Parameters:
key
- the key to look upmap
- the map represented as a StringdefaultValue
- the default value- Returns:
- the element found in the map with the given key, or the default value
-
mathCeil
Calculates the next largest integer for the given number parameter.Note that the result is an Object of type
Long
, so in case the parameter can not be converted to a number,null
is returned.- Parameters:
param
- an Object that will be converted to a number- Returns:
- the next largest integer for the given number parameter
-
mathFloor
Calculates the next smallest integer for the given number parameter.Note that the result is an Object of type
Long
, so in case the parameter can not be converted to a number,null
is returned.- Parameters:
param
- an Object that will be converted to a number- Returns:
- the next smallest integer for the given number parameter
-
mathRound
Calculates the next integer for the given number parameter by rounding.Note that the result is an Object of type
Long
, so in case the parameter can not be converted to a number,null
is returned.- Parameters:
param
- an Object that will be converted to a number- Returns:
- the next integer for the given number parameter calculated by rounding
-
parseJson
Parses JSON object.- Parameters:
value
-- Returns:
-
repairHtml
Repairs the given HTML input by adding potentially missing closing tags.- Parameters:
input
- the HTML input- Returns:
- the repaired HTML or an empty string in case of errors
-
stripHtml
Strips all HTML markup from the given input.- In case the input is an instance of
CmsJspContentAccessValueWrapper
, an optimized method is used for the HTML stripping. - Otherwise the input is converted to a String and this String is stripped.
- Parameters:
input
- the input to Strip from HTML- Returns:
- the given input with all HTML stripped.
- In case the input is an instance of
-
toNumber
Converts the given Object to a (Double) number, falling back to a default if this is not possible.In case even the default can not be converted to a number,
-1.0
is returned.- Parameters:
input
- the Object to convert to a (Double) numberdef
- the fall back default value in case the conversion is not possible- Returns:
- the given Object converted to a (Double) number
-
trimToSize
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 trimlength
- the maximum length of the string to be returned- Returns:
- a substring of the source, which is at most length characters long
- See Also:
-
validateRegex
Validates a value against a regular expression.- Parameters:
value
- the valueregex
- the regex- Returns:
true
if the value satisfies the validation
-
${cms.requestContext.uri}
instead.