Friday, April 10, 2009

How to force the WCM rendering portlet to show the default content


Question
The Workplace Web Content Management™ (WCM) rendering portlets have default content that they are configured to show. When a user clicks a link that updates the portlet to display updated content, if the user clicks away from the portlet and clicks back, the updated content still displays.

Cause
There is no actual problem with this scenario. This is the expected behavior of the portlet, because it is designed to maintain its state even when navigating away from the Portal page.

Answer
One way to force the Web content viewer portlet to display the default content is to override the link to the Portal page that contains the portlet. To update a WCM portlet with new content, place the following string at the end of the link to the page:

For Web Content Management version 6 and above:


?WCM_GLOBAL_CONTEXT=/wps/wcm/myconnect/library/site/sitename/content


For earlier versions of Web Content Management:


?WCM_GLOBAL_CONTEXT=/wps/wcm/myconnect/site/sitename/content


It can be simple to do this override when writing links within WCM to this content, but how do you force it in the WebSphere Portal navigation? For example, you have a page in WebSphere Portal named "Home." You want the WCM content displayed within to always be the default when the user clicks on the Home page tab.

One solution is to customize the WebSphere® Portal theme, and override the functionality that is providing the links. In the Default.jsp in the IBM sample theme, there is a file named topNav.jsp that generates these links. Once you know the name of the page, and the default WCM content that you want to be displayed, you can override the links to always force the default content.

In the IBM provided file, this change would be from this code:








  • To the following code:



  • <%
    String myString = wpsNavNode.getContentNode().getTitle(request.getLocale());
    if(!myString.equalsIgnoreCase("CKTestSearch")) {
    %>

    <%} else { %>

    <%}%>





  • In this example, the WebSphere Portal page was named "CKTestSearch", and WebSphere Portal is version 6.


    Additionally, if the default content in the portlet is going to be changing, in order to not have to constantly update the navigation jsp the portlet can be forced to always display the default content for the portlet. To accomplish this, in the above sample, leave the WCM_GLOBAL_CONTEXT= blank.

    So, instead of
    ?WCM_GLOBAL_CONTEXT=/wps/wcm/myconnect/Library/Site/SiteArea/ContentName
    Use
    ?WCM_GLOBAL_CONTEXT=

    That way, when nothing is passed to the portlet, it will default to the default content for the portlet.