<< Back - Alkacon logo

OpenCms 6.0 interactive documentation:

Documentation for the include() method

OpenCms logo - Forward >>

The include() method

This method is used to include files from the OpenCms VFS dynamically at runtime. The included file is treated like a request with optional additional request parameters.

Parameters:

Name Description
java.lang.String target The URI of the included resource in the OpenCms VFS.

Parameters:

Name Description
java.lang.String target see above
java.lang.String element If the included JSP page is split into elements by the template() method, only the specified element of the JSP page is included.

Parameters:

Name Description
java.lang.String target see above
java.lang.String element see above
java.lang.boolean editable Marks that the included page element is editable via the "direct edit" feature.
Note: It is necessary to use the cms.editable() method in head of the JSP to enable the direct edit function on this JSP.

Parameters:

Name Description
java.lang.String target see above
java.lang.String element see above
java.util.Map parameterMap Additional parameters that are passed to the included file.

Parameters:

Name Description
java.lang.String target see above
java.lang.String element see above
java.lang.boolean editable Marks that the included page element is editable via the "direct edit" feature.
Note: It is necessary to use the cms.editable() method in head of the JSP to enable the direct edit function on this JSP.
java.util.Map parameterMap see above

Example usage:

Include the JSP page "some_page.html":

org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response); 

cms.include("some_page.html");

Read the name of the file to be included from the property "template" on the current file:

org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response); 

cms.include(cms.property("template"));

Add additionally some key/value coded parameters to the request parameters hashtable to pass them to the included file:

org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response);
java.util.HashMap parameters = new java.util.HashMap();

parameters.put("__locale", locale);
parameters.put("__navpart", "toprow");

cms.include("../elements/template-nav-top.jsp", null, parameters);

Include the element "head" from the JSP page specified by the "template" property:

org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response); 

cms.include(cms.property("template"), "head");

Include the direct editable page element "body":

org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response); 

cms.include(null, "body", true);

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