For Developers

Dynamic function demo

Since OpenCms 8 a resource type "Dynamic Function" has been introduced. This resource type makes it possible to drag and drop a dynamic content provided by a jsp directly into a containerpage of the website.

Use Case: A typical use case is extending the website by a search or a login functionality.

Example: In this demo example a simple date display is added to a box, which can be dropped in one of the side containers. The settings are used to set the format of the date. The locale is provided by a request parameter defined for the dynamic function.

How to use "Dynamic Function":

  • Drop a new resource of type "Dynamic Function" into the containerpage and edit it in the XML content editor from ADE.
  • Set the title to indicate this dynamic function from another in the add wizard in ADE.
  • Select the path to the JSP which provides the required functionality in the field "Function provider".
  • Add optional request parameters if required in the field "Parameters".
  • Optional formatter configuration for this dynamic function element can be set in the field "Formatter options". You can restrict the type of the container as well as its min or max width to control in which template container this dynamic function resource can be dropped.

Additionally define the settings in the second tab directly in the XML content editor. Use the same options as inside the schema definition for the resource type.

Important note: The HTML output provided by the used JSP should be surrounded by a <div> tag, similar to the formatter jsp.

Dynamic Function Demo.

Saturday, April 26, 2025
Settings:
  • Format: date
  • Style: full
Parameters:
  • locale: en_US