Thursday, June 4, 2009

Customizing the Portlet Unavailable message



Question
How can you provide a different error message than Portlet Unavailable, based upon the portlet involved?

Answer
You have a few options to customize the Portlet Unavailable message. First, look at one of your skins, such as the following one:

\WebSphere\profiles\wp_profile\installedApps\wpsbvt\wps.ear\wps.war\skins\html\IBM

In that location is the control.jsp file that calls the portlet to render with the following tag:





Therefore, the body of the tag is only rendered if the portlet has a problem. The program uses a key passed by the portal engine to determine what value to pull from the resource bundle. More information on the problem format tag can be found in the Information Center topic " tags."

So, you could create a new skin for your specific portlets and enter your own custom text there. Or you can use the fmt tags and pull a different key from the regular text bundle.

All of these resource bundles are stored in the wp.ui.jar file in the portalserver/shared/app directory.

For the English language, you use the problem_en.properties file. In that file, you see the following line:


    portlet.not.available = This portlet is unavailable.

You can change that text to whatever you wish. Note that the text you enter will be the same for every portlet that is unavailable.

If you want only the Web Content Management (WCM) portlets to return a different message, you need to replace this line:



With something like the following:


Then you add a line to the engine_en.properties file in wp.ui.jar like this:

    wcmproblem = The WCM portlet could not be rendered

You would need to add a line like that to every language file for engine_XX.properties.

You can also suppress the Portlet Unavailable error messages.