<< Back - Alkacon logo

OpenCms 6.0 interactive documentation:

OpenCms JSP scriptlet documentation

OpenCms logo - Forward >>

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: org.opencms.jsp.CmsJspActionElement. To develop JSP pages using the OpenCms API, programmers are not fixed to a certain approach. Both the OpenCms JSP taglib and the CmsJspActionElement offer the same options. In fact, both ways execute the same internal code! Experienced Java programmers can find an equivalent method in the Bean CmsJspActionElement for each tag of the OpenCms Taglib. For a detailed description of the OpenCms JSP Taglib, please refer to the OpenCms JSP Taglib documentation which is available as a separate module.

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 CmsJspActionElement can also be created by passing these values as parameters to the CmsJspActionsElement's second constructor like this:

<% 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.

folder Javadocs for the CmsJspActionElement

Java programmers can find here the complete Javadocs for the CmsJspActionElement.

file Documentation for the user() method

This method provides access to read the properties of the current user.

file Test for the user() method

A test displaying various properties of the currently logged in user.

file Documentation for the property() method

This method provides access to read the properties of the current file.

file Test for the property() method

A test reading various file properties from different files in the OpenCms VFS.

file Documentation for the link() method

This method acts as a wrapper to build a valid OpenCms URL for a given resource.

file Test for the link() method

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.

file Documentation for the label() method

This method provides access to read the localized strings from the OpenCms workplace Java resource bundles.

file Test for the label() method

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.

file Documentation for the editable() method

This method includes direct edit scriptlets.

file Documentation for the include() method

This method includes other JSP elements dynamically at runtime.

file Test for the include() method

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.

file Test for the include() method with parameters

This test shows how to pass parameters to included JSP sub-elements.

file Documentation for the template() method

This method checks if a template part should be used or not.

file Test for the template() method

Example JSP page showing how to include parts from another JSP page.

file JSP page with two simple template elements

The elements in this JSP page are included by test_method_template.jsp

file Documentation for the info() method

This method prints various runtime information of your system.

file Test for the info() method

A test to print all runtime information available by the info() method.

file Documentation for the getNavigation() method

This method returns an initialized CmsJspNavBuilder instance to create a navigation.

file Test for the getNavigation() method

A test building a navigation of the current folder.

©2003-2005 Alkacon Software (http://www.alkacon.com) - The OpenCms experts