How to get the friendly name of current Portal navigation node ?

If you need to find out which page are you on currently, you have to spend a lot of time on Google or reading Portal SPI and extracting different jar files all over the Portal installation folder.

WebSphere Portal 7 and higher contains portal session object 'wp' which contains different functions and data contained within it. Everything what is contained within this object can be examined by decompiling several classess, since official documentation doesn't exist.

However, from Portlet jsp file, since it has access to HttpServletSession, or portal session, you can write something like this:

<c:set var="currenturl" scope="request" value="${wp.selectionModel.selected.metadata['com.ibm.portal.friendly.name']}" />

Variable 'currenturl' now contains friendly name of current navigation node.

This is far more simple then instantiating a lot of portal services and of writing java scriptlets within jsp which at times looks very ugly.

Another example to get the display name of the currently selected page:

<c:out value="${wp.user['displayName']}" />

No comments:

Post a Comment