"Hello User" Include Example

Posted in ECM & UCM.

*This is adapted from the text The Definitive Guide to Stellent Content Server Development, by Brian Huff.

The most common resource is a dynamichtml include, which contains HTML and IdocScript code and is used on template pages. Most of the look and feel of the Content Server is contained in dynamichtml includes, instead of being coded directly on template pages, which makes Content Server much easier to customize.

The format of a resource include is the same as an IDOC resource.
However, an include defined in a component is available on all pages, provided that the component is enabled.

To create a custom include, follow these steps:

  1. Open up the Component Wizard.
  2. Click Add to add a new component.
  3. Name the component HelloUser, and click OK in all open dialog boxes.
  4. Wait for the Component Wizard to create and open the HelloUser component.
  5. In the Resource Definitions tab, click Add.
  6. Select Resource–HTML Include/String and click Next.
  7. Name the include hello_user, and in the text box type the following code: <h1>Hello <$UserName$>!</h1>
  8. Click Finish.
  9. In the menu, select Options ?Enable to enable the component.
  10. Restart the Content Server.

You might be prompted to open this file with a text editor. Most people prefer third-party text editors to the minimalistic one provided in the
Component Wizard. You can set a default text editor from Options ?Configuration on the
menu bar.

After the preceding steps, we have a basic component with one resource and one HDA file containing the configuration information for the component:

Component Definition File:    stellent/custom/HelloUser/HelloUser.hda

Include:    stellent/custom/HelloUser/resources/hellouser_resource.htm

The Include file definition begins with a dynamichtml tag, which contains the name of the include. The definition ends with the end tag.

As with definitions in IDOC files,the beginning and ending of resources are controlled with keywords delimited with <@ and @> characters.

The IdocScript in the include must use standard IdocScript, delimited with <$ and $> characters. XML IdocScript is not supported in resource definitions.


The next step is to create a template page so we can display the resource.

Several kinds of pages can display dynamichtml includes, such as:

  • Core Content Server templates
  • Hypertext Content Server Templates (HCSTs)
  • Java Server Pages (JSPs)
  • Hypertext Content Server Pages (HCSPs)
  • Hypertext Content Server Forms (HCSFs)

For a quick test, we can create an HCST that includes the following resource:

<$include hello_user$>

Alternatively, We can create a custom template for the include. To display a custom template, we also need a custom service. To do this, follow
these steps:

  1. Open the Component Wizard and the HelloUser component.
  2. In the Resource Definitions tab, click Add.
  3. Select Template and click Next.
  4. Click Next.
  5. Set the name to HELLO_USER_PAGE.
  6. Set the Class to Pages.
  7. Set the Form Type to HelloUser.
  8. Set the File Name to hello_user_page.htm.
  9. Click Finish.
  10. 1In the Resource Definitions tab, click Add.
  11. Select the Service button and click Next.
  12. Click Next.
  13. Name the service HELLO_USER.
  14. Set the Service Class to Service.
  15. Click Finish.
  16. Restart the Content Server.

After these steps, you have the following files in your component:

  • stellent/custom/HelloUser/resources/hellouser_service.htm
  • stellent/custom/HelloUser/templates/hellouser_template.hda
  • stellent/custom/HelloUser/templates/hello_user_page.htm

The hellouser_service.htm resource contains the HTML table defining the HELLO_USER service. It does very little besides display the HELLO_USER_PAGE.

The hellouser_template.hda resource contains a table with descriptive information about each template. The template HELLO_USER_PAGE is defined in hello_user_page.htm:

The generated hello_user_page.htm template initially has very little in it. We should change it so that it looks more like the HCST we used for testing in the previous section:

<meta http-equiv="Content-Type" content="text/html;
<$include hello_user$>

The Component Definition File HelloUser.hda was also changed to include the new resources in the ResourceDefinition result set. The MergeRules result set has also changed to merge the custom templates into the core templates.@ResultSet MergeRules.

To test your new page, manually enter a URL to your Content Server to execute the service:

Like resource includes, templates can be modified without restarting the Content Server.
However, if a new template is added, you need to restart the Content Server. Any change to the service definition also requires a server restart.

You can place IdocScript in a dynamichtml resource or directly into the template. Which is the better choice?

In general, dynamichtml resources are more flexible and should be used to encapsulate asmuch code as possible, which eases portability because your code can now be reused by other templates. Resource includes also ease compatibility with existing components and make your code more forward compatible. Resource includes can be customized many times in many different components, whereas a template page can be customized only once. 

About Me

I currently specialise in developing bespoke applications using Oracle APEX.I have worked with APEX since it was known as HTMLDB, but have also dabbled with E-Business Suite, Oracle AS Portal, ECM, Webcenter and Website Design.

I enjoy working with new clients and assisting them develop custom applications to enhance and improve internal business processes.

Find Me

mandy nerd2