Dynamic Portlet Title - Websphere Portal

There are two known alternatives to support dynamic titles in websphere portal.

First, the portlet content can be buffered into a stored response; then you can first transfer the title to the portal page output stream before the portlet response. This buffering solution has a big performance impact because all portlet content needs to be kept in memory for later access and once again transferred to the response from the buffer. Because of this performance impact, WebSphere Portal does not use this design for dynamic titles.

The second alternative is to use JavaScript, along with streaming (instead of buffering). JavaScript is browser-specific and is often seen as security risk; for this reason (and others) JavaScript is sometimes not accepted by some enterprises. However, if you can use JavaScript you can write the title to the output stream and replace it later in the browser. There is no noticeable performance impact. This solution is the recommended way to add dynamic title support with WebSphere Portal V6.

Beginning with Version 6 of WebSphere Portal, when a title is set by RenderResponse.setTitle(String title), it is transferred to the request attribute, com.ibm.portal.portlet.Constants.DYNAMIC_TITLE. Therefore, the dynamic title is available after the portlet content has been rendered using the portal tag portletRender. The skin JSP can access the portlet title (set by the portlet during run time), as soon as the portlet has finished rendering, using the DYNAMIC_TITLE request attribute.

Important: This attribute is not scoped by portlet; therefore, the title is lost as soon as the next portlet is rendered

Steps below explains to enable dynamic portlet titles using JavaScript

Step 1:  To enable the static title to be replaced later, the title needs to be marked within the portlet skin using the HTML elements <span> or <div>. The element must be uniquely identifiable by using the id attribute because it might appear multiple times on a portal page.

Step 2: Search for the portletTitle tag in your portlet skin that retrieves the static portlet title, and surround it with a span element as shown here.

<span id="title.<portal-skin:portletID/>">
<portal-fmt:problem bundle="nls.problem"/>

Step 3: At the end of the portlet skin, you can retrieve the title that was dynamically set during portlet rendering to replace this spanned static title fragment. You can use the DYNAMIC_TITLE request attribute to acces the dynamic title

script type="text/javascript">
var dynamicTitle =
var titleElement =
if (titleElement != null) {
if (dynamicTitle != "" && dynamicTitle != "null")
titleElement.innerHTML = dynamicTitle;

Click here for additional resources

1 comment:

  1. ok, didn't notice that you really linked to the actual article...