Deployment Example: Deploying and Customizing the Documentum Portlet

Namespace in Portlets

The JSR-168 specification for portal servers specifies that the URIs, element name attributes, and JavaScipt methods should be encoded with the namespace of that portlet. Use the IRender method namespaceElement(strPortletInstanceName) to encode these elements. In the following example, a form element is encoded for portal PC_202:

<% IRender render = EnvironmentService.getEnvironment().getRenderContract();%>
<FORM method=POST name="<%=render.namespaceElement("form1")%>" action="">

The form element will then be rendered as follows:

<FORM method=POST name="PC_202_form1" action="">

To encode JavaScript with the portal namespace, WDK provides a servlet and VirtualJS. This servlet rewrites static JavaScript files to portlet-specific versions, changing method names and any form variable names that are used to the appropriate portal-specific namespace. The servlet is used by tag rewrite methods in a portal environment, so that the tags no longer point to static JavaScript files but to dynamic versions hosted by the servlet. For example, the following JavaScript declaration in a WDK page:

<script src="/wdk/wdk/include/events.js" language="javascript1.2">

is rewritten to:

<script src="/wdk/virtualjs/PC_202/wdk/include/events.js"

The servlet delegates the rewriting of JavaScript files to Java classes that implement the IJavaScriptHandler interface. JavaScript files that must be rewritten are registered for a particular handler class by adding entries into the file located in /WEB- INF/classes/com/documentum/web/env directory.