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 windowString 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; } }

The first line of code does not work for me using JBoss EPP 4.3 and RichFaces. I get this message: java.lang.ClassCastException: org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl cannot be cast to org.jboss.portlet.JBossRenderRequest
So I did i this way and it worked!
PortalNode node = Navigation.getCurrentNode();
Then I switched all of your “req.getPortalNode().” to “node.” and it worked fine. Weird!
May i know how to access all these from this page? deploy/jboss-portal.sar/portal-server.war/login.jsp…
I have 2 different portals in my jboss and they have different login pages… i am trying to differentiate the portals in login.jsp and redirect their page to their related login pages…
if i try to get the portal like this–>> PortalNode node = (PortalNode)request.getAttribute(”org.jboss.portal.api.PORTAL_NODE”); it throws null pointer!..
Thank you for your very useful blog…
Thanks.. This Information was useful
You gave great points here. I did some research on this subject and have found nearly all people agree with your website.
Sent from my Android phone