25.2. Header

25.2.1. Overview

The default header is divided into two parts, links to pages displayed as tabs and links to navigate between portals and dashboards as well as logging in and out. Those two parts are included into the template thanks to the layout as defined in Section 25.3, “Layouts”. In fact, the region named, dashboardnav will include the navigation links, while the region named navigation will include the navigation tabs. It is then easy to hide one and/or the other by removing the corresponding inclusion in the layout.
Screenshot of the header with the 'renaissance' theme


Here, we use split content from rendering by using a CSS style sheet, it allows us to change the display by switching the CSS without affecting the content. The Maple theme will display the links on the left side with a different font for example. This is up to you to choose or not this approach
To customize the header there are several options detailed after.
  • The first option would simply require to modify the theme CSS, by doing this you could change the fonts, the way tabs are rendered, colors and many other things but not change the content.
  • The second option is to modify the provided JSP files, header.jsp and tabs.jsp. It gives you more flexibility than the previous solution on modifying the content. Links to legacy application could easily be added, URLs could be arranged differently, the CSS approach could be replaced by good old HTML, CSS style names could be changed... The drawback of this method compare to the next one is the limitation in what is accessible from the JSP. Writing his own JSP™ pages

The content of those two parts are displayed thanks to two different JSP™ pages. By default you would find those pages in the directory portal-core.war/WEB-INF/jsp/header/. The file header.jsp is used to display the links that are displayed on the upper right of the default theme. The file tabs.jsp is used to display the pages tabs appearing on the left.
Again, you have several choices, either to edit the included JSP files directly or create your own, store them in a web application then edit the following file: jboss-portal.sar/META-INF/jboss-service.xml. The interesting part in that file is the following:
   <attribute name="TargetContextPath">/portal-core</attribute>
   <attribute name="HeaderPath">/WEB-INF/jsp/header/header.jsp</attribute>
   <attribute name="TabsPath">/WEB-INF/jsp/header/tabs.jsp</attribute>
The three attributes are:
  • TargetContextPath: Defines the web application context where the JSP files are located
  • HeaderPath: Defines the location (in the web application previously defined) of the JSP in charge of writing the header links
  • TabsPath: Defines the location (in the web application previously defined) of the JSP in charge of writing the pages links (note that it doesn't have to be renderer as tabs)
Writing the header JSP
A couple of request attributes are set so that they can be used by the JSP, here is the list of attributes and their meaning:
  • org.jboss.portal.header.USER: A org.jboss.portal.identity.User object of the logged-in user, null if the user is not logged-in.
  • org.jboss.portal.header.LOGIN_URL: URL to logging-in.
  • org.jboss.portal.header.DASHBOARD_URL: URL to the dashboard, null if the user is already on the dashboard, null if the user is on the default portal already.
  • org.jboss.portal.header.DEFAULT_PORTAL_URL: URL to the default page of the portal named 'default', null if the user is on the default portal already.
  • org.jboss.portal.header.ADMIN_PORTAL_URL: URL to the default page of the admin portal (named 'admin'), null if the user is on the admin portal already.
  • org.jboss.portal.header.EDIT_DASHBOARD_URL: URL to the page content editor of the dashboard, set only if the user is on the dashboard, null otherwise.
  • org.jboss.portal.header.COPY_TO_DASHBOARD_URL: URL to copy a page from a portal to the personal dashboard, null if the user is on the dashboard.
  • org.jboss.portal.header.SIGN_OUT_URL: URL to log out the portal.
Every attribute that is an URL attribute is an object implementing the org.jboss.portal.api.PortalURL interface. Therefore it is possible to generate the URL using the toString() method and change various things related to the URL. With that in hand, if someone just wanted to display the logged-in username and a link to log out, he could write:
<%@ page import="org.jboss.portal.identity.User" %>

   User user = (User) request.getAttribute("org.jboss.portal.header.USER");
   PortalURL signOutURL = (PortalURL)request.getAttribute("org.jboss.portal.header.SIGN_OUT_URL");
   PortalURL loginURL = (PortalURL)request.getAttribute("org.jboss.portal.header.LOGIN_URL");

   if (user == null)
   <a href="<%= loginURL %>">Login</a>
Logged in as: <%= user.getUserName() %>
<a href="<%= signOutURL %>">Logout</a>
Writing the tabs JSP
A couple of request attributes are set so that they can be used by the JSP, here is the list of attributes and their meaning:
  • org.jboss.portal.api.PORTAL_NODE: A org.jboss.portal.api.node.PortalNode object of the root Portal node. Authorized children and siblings of this object are accessible.
  • org.jboss.portal.api.PORTAL_RUNTIME_CONTEXT: A org.jboss.portal.api.PortalRuntimeContext object that can be used to render URLs.
The default file in charge of displaying the tabs can be found in: portal-core.war/WEB-INF/jsp/header/