HTML Headers -- Using Default Implementation

The Toolkit provides a default implementation for writing HTML header information in Web pages; no subclassing is required. The following example shows the type of header information that is generated:

<head>
   <base href='http://fluffy:7001/customApp/'>
   <title>Sign In</title>
   <link rel='stylesheet' href='http://fluffy:7001/customApp/css/myCss.css' type='text/css'>
   <script>var baseURL = "http://fluffy:7001/customApp";</script>
   <script src='http://fluffy:7001/customApp/js/myScript.js'></script>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <meta name='BuildName' content='release 1.0'>
   <meta name='BuildDate' content='03/04/2003'>
   <meta name='Copyright' content='Copyright © 2003 Acme Corporation. All
   rights reserved.'>
</head>

The WcmHeaderModule class writes out the elements nested in the HEAD tag. It includes accessor methods for setting properties such as title, build information, CSS and JavaScript file names, and includes render methods for writing out the elements.

The steps and diagram below describe how the default implementation works. When an event Java™Server Pages (JSP) page is loaded:

  1. The controller's configurePage(...) is invoked, derived from WcmController. This method calls into configureHeaderModule( ).
  2. The configureHeaderModule( ) method constructs a WcmHeaderModule object, and registers it with the controller.
  3. The controller does a server-side redirect to the UI JSP page.
  4. In the UI JSP page, the WcmUi.renderHeaders(...) method is invoked.
  5. The WcmUi.renderHeaders( ) method calls WcmHeaderModule.renderJSP(...), derived from WcmUiModule.
  6. If WcmUiModule.setJSP(...) had previously been called to set a JSP page for rendering, then the renderJSP(...) method passes the path of the rendering JSP to the controller's serverSideInclude(...) method. Otherwise, the renderJSP(...) method calls WcmHeaderModule.render(...).

HTML header implementation

To leverage the default implementation:

  1. In a UI module or a UI JSP page, set properties of the WcmHeaderModule object instantiated in WcmController.configureHeaderModule( ), such as CSS and JavaScript files. You can retrieve the WcmHeaderModule object with the getHeaderModule(...), a static method of WcmUi. For example:

    WcmHeaderModule h= (WcmHeaderModule) WcmUi.getHeaderModule(request);

  2. In your UI JSP page, call renderHeaders(...), another static method of WcmUi. For example:

    WcmUi.renderHeaders(request, out)

    This initiates the calling chain into WcmHeaderModule.render(...)

NOTE   If you want to use the Toolkit's date/time functionality, you must use HeaderModule, a subclass of WcmHeaderModule. See Date/Time API.