Category: JBoss Portal

How to get the JBoss Portal window name, page name, and portal name for a JSF portlet

Posted by on January 12, 2009

Recently I needed one of my JSF portlets running in JBoss Portal to know some information about itself.  The information I needed was:

  • Window name
  • Page name
  • Portal name

Surprisingly it was not easy to figure out how to do this. Not because it’s not feasible, it’s just that the information was simply not there for the common developer to find (forums, Google, etc.).  So I thought it would be worthwhile to share my findings.

This is what you need to do:

// Get render request object that contains needed info
JBossRenderRequest req =
    (JBossRenderRequest) FacesContext.getCurrentInstance()
        .getExternalContext().getRequest();
// Extract window name for this portlet
String windowName = req.getPortalNode().getName();
// Extract page name for this window
String pageName = req.getPortalNode().getParent().getName();
// Extract portal name
String portalName = null;
PortalNode portalNode = req.getPortalNode();
PortalNode rootNode = req.getPortalNode().getRoot();
while (true) {
    portalNode = portalNode.getParent();
    if (!rootNode.equals(portalNode)) {
        portalName = portalNode.getName();
    } else {
        break;
    }
}