Simple calculator

 

Dynamic Function detail page demo

The dynamic function resource type make it possible to integrate jsp functionality directly on the website. The function element points to the required  jsp and can be directly dropped into the container page.

Use Case:  Collecting data in a form on the webpage and sending this information to another jsp for further evaluation, e.g. integration of a search form on several page of the website.

The results of the evaluation, e.g. search results, are displayed on a predefined page in the navigation on the website. Since OpenCms 8.0.3 you can use function detail page to define such a result page.

 

To use the function detail page for the function element following steps are required:

  • Create function element in the module.
  • Configure the function detail page for the created function element.
  • Drag & drop the function detail page to the website structure using the sitemap editor.

 

Configuration of the function detail page

  • Implement the jsp containing a form to be used on several container pages of the website. Use the following value "${cms.functionDetail["Name of the function detail"]}" as attribute "action" of the <form> tag.
  • Implement the second jsp, which evaluates the form data and generates the html output to be shown as detail view.
  • In explorer view create two dynamic function elements using New-Dialog inside of the module. One of the dynamic functions should point to the form jsp and another to the detail page jsp.
  • Define the function detail page in the module configuration to use it in the sitemap editor. Add new field to the tab "Function". Define a unique name for the function detail. This should be the same name, which is used in the form jsp as action parameter. Select the dynamic function element, which displays the form results.

Edit property "container.info" on the template jsp. Set the property value to:

functionDetail=centercolumn

where "centercolumn" is the attribute "name" of the <cms:container>, where the results are displayed.

 

 Using the function detail page on the website

  • Drop the dynamic function element containing the form to the page in ADE.
  • Click on the plus icon in the sitemap editor to drag & drop a new page to the website navigation.
  • Use the configured function detail page from tab "Function Pages" as page model.

 

Compare follwing resources for implementation details:

 /system/modules/org.opencms.dev.demo/.config

/system/modules/org.opencms.dev.demo/functions/

/system/modules/org.opencms.dev.demo/pages/simple-calculator-form.jsp

/system/modules/org.opencms.dev.demo/pages/simple-calculator-result.jsp

/system/modules/org.opencms.dev.demo/templates/main.jsp