How to write JSP scriptlet code using the OpenCms API
The functionality of the OpenCms JSP Taglib can also be accessed by
using a single Java Bean:
Put this code snippet in the head of your JSP page to initialize the CmsJspActionElement as a Java Bean:
<jsp:useBean id="cms" class="org.opencms.jsp.CmsJspActionElement"> <% cms.init(pageContext, request, response); %> </jsp:useBean>
Because the CmsJspActionElement requires the current
pageContext, request and response instances, you do have to invoke the init()
method! Alternatively, an instance of
<% org.opencms.jsp.CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response); %>
The next pages describe the usage of the different methods provided with the CmsJspActionElement. The Javadocs for the CmsJspActionElement are included, too.
Java programmers can find here the complete Javadocs for the CmsJspActionElement.
This method provides access to read the properties of the current user.
A test displaying various properties of the currently logged in user.
This method provides access to read the properties of the current file.
A test reading various file properties from different files in the OpenCms VFS.
This method acts as a wrapper to build a valid OpenCms URL for a given resource.
This test uses the link() method to get some link substitutions for different files. This method is required in case you want to use the static export.
This method provides access to read the localized strings from the OpenCms workplace Java resource bundles.
This method can read out values from the OpenCms Workplace Java resource bundles. This can be used in case you want to build Workplace extensions and intend to make them language independent.
This method includes direct edit scriptlets.
This method includes other JSP elements dynamically at runtime.
This very important method allows you to include sub-elements on a page. These sub-elements can be cached, please see the FlexCache description for more details.
This test shows how to pass parameters to included JSP sub-elements.
This method checks if a template part should be used or not.
Example JSP page showing how to include parts from another JSP page.
The elements in this JSP page are included by test_method_template.jsp
This method prints various runtime information of your system.
A test to print all runtime information available by the info() method.
This method returns an initialized CmsJspNavBuilder instance to create a navigation.
A test building a navigation of the current folder.