EL functions provided by OpenCMS taglib
(→cms:vfs) |
|||
Line 11: | Line 11: | ||
${cms:vfs(pageContext).context.locale} | ${cms:vfs(pageContext).context.locale} | ||
+ | |||
+ | The CmsJspVfsAccessBean provides some lazyly loaded maps. | ||
+ | |||
+ | ==== Resouces ==== | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <c:if test="${cms:vfs(pageContext).exists['/checkme.html']}" > | ||
+ | |||
+ | ${cms:vfs(pageContext).resource['/checkme.html']} | ||
+ | |||
+ | </c:if> | ||
+ | </source> | ||
+ | |||
+ | ===== Properties ===== | ||
+ | |||
+ | You can use two maps, one for non-searched and second for searched property values. Searched means that if the property is not set for the resource, its parent folders are searched. | ||
+ | |||
+ | Title property of the "/index.html" resource: ${cms:vfs(pageContext).property['/index.html']['Title']} | ||
+ | |||
+ | Title property of the "/index.html" resource (searched): ${cms:vfs(pageContext).propertySearch['/index.html']['Title']} | ||
+ | |||
+ | |||
+ | ==== XML content ==== | ||
+ | |||
+ | The returned map values are of type [http://www.opencms.org/javadoc/core/index.html?org/opencms/jsp/util/CmsJspContentAccessBean.html CmsJspContentAccessBean]: | ||
+ | |||
+ | ${cms:vfs(pageContext).xml['/text.xml'].value['Title']} | ||
=== cms:convertDate === | === cms:convertDate === |
Revision as of 11:22, 20 September 2010
The OpenCMS taglib provides tags, but also functions. You can see their definition in the WEB-INF/opencms.tld file, the functions themselves are provided by the CmsJspElFunctions class.
Just declare the taglib as usual:
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
Contents |
cms:vfs
Provides access to VFS (Virtual File System), returns an instance of org.opencms.jsp.util.CmsJspVfsAccessBean. Example:
${cms:vfs(pageContext).context.locale}
The CmsJspVfsAccessBean provides some lazyly loaded maps.
Resouces
<c:if test="${cms:vfs(pageContext).exists['/checkme.html']}" > ${cms:vfs(pageContext).resource['/checkme.html']} </c:if>
Properties
You can use two maps, one for non-searched and second for searched property values. Searched means that if the property is not set for the resource, its parent folders are searched.
Title property of the "/index.html" resource: ${cms:vfs(pageContext).property['/index.html']['Title']}
Title property of the "/index.html" resource (searched): ${cms:vfs(pageContext).propertySearch['/index.html']['Title']}
XML content
The returned map values are of type CmsJspContentAccessBean:
${cms:vfs(pageContext).xml['/text.xml'].value['Title']}
cms:convertDate
Allows conversion of Long values to Dates. For example to display the time of last modification of a page:
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %> <%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %> ... <f:formatDate value="${cms:convertDate(cms:vfs(pageContext).resource[cms:vfs(pageContext).context.uri].dateLastModified)}" pattern="yyyy-MM-dd HH:mm:ss" />
cms:getCmsObject
Returns the current OpenCms user context form the page context.
cms:convertLocale
Allows conversion of Objects to Locales. Can also handle Strings that are locales, or Locales itself. If no valid locale is provided, the OpenCms default locale is returned.
cms:stripHtml
Strips all HTML markup from the given input.
cms:trimToSize
Returns a substring of the input, which is not longer then the given int value.
${cms:trimToSize('aaabbb',3)}
cms:convertUUID
Allows conversion of String values to CmsUUIDs. Can also handle byte[] that are CmsUUIDs, or CmsUUID itself.
cms:getRequestParam
Returns the value of a parameter from a String that is formatted for a GET request.
cms:getRequestLink
Returns the link without parameters from a String that is formatted for a GET request.
cms:escape
Encodes a String in a way that is compatible with the JavaScript escape function.
cms:unescape
Decodes a String in a way that is compatible with the JavaScript unescape function.