Creating custom layouts in JBoss Portal

The layout of a portlet is handled by a set of JSP in the portal-core web-app which is part of the jboss-portal.sar. In the web-inf direcotry have a look at portal-layouts.xml to see how various layouts are configured. The following is a snippet (self explainatory):

<layouts>
<layout>
  <name>rbs-1column</name>
  <uri>/layouts/mylayout/index.jsp</uri>
  <uri state="maximized">/layouts/mylayout/maximized.jsp</uri>
  <regions>
    <region name="regionBody"/>
  </regions>
</layout>
</layouts>

You can make changes to these JSPs and the portal-layouts.xml. Alternatively (recommended), create you own theme in a separate web app (war file) and change the following config in jboss-portal.sar/META-INF/jboss-service.xml. You need to change the fillowing lines:

  • Change layout context path: <attribute name="TargetContextPath">/mylayoutapp</attribute>
  • Change path to header jsp: <attribute name="HeaderPath">/WEB-INF/jsp/myheader.jsp</attribute>
  • Change path to tabs (navigation) jsp: <attribute name="TabsPath">/WEB-INF/jsp/mynavigation.jsp</attribute>

The new war file will need to have access to the to portal lib tag-libs. These can be found at jboss-portal.sar/portal-core.war/WEB-INF.  Your layout JSP specified as “url” in the portal-layouts.xml will need to include the following directives:

  • In the html header: <p:theme themeName=”mytheme”/>, <p:headerContent/>.  See http://java.dzone.com/articles/jboss-portal for a guide on creating custom themes.
  • In the body: <p:region regionName=’regionBody’ regionID=’regionBody’ />. This will need to be added for all the regions defined in the portal-layout.xml for this particular layout.

Note: Theme and layouts can be specified in the portal page deployment descriptor (see property theme.id and layout.id)

Advertisements

WSRP the Ideal and the Actual

Web Services for Remote Portlets (WSRP) is a very useful spec. It defines standards to provide “presentation oriented web services” that can be used to aggregate web sites. It is a much richer way of providing site mashups. WSRP not only allows mashing up at the HTML level but also concerns itself with passing application state and security contexts between the aggregators and source websites (Portlet Consumers and Portet Producers respectively). Most Portal Platforms now days provide an implementation of WSRP which is now at version 2.0 .

I’ve recently tried to use this feature in JBoss Portal Server and Websphere Portal with mixed results. My main issue is that the URL handling (e.g. image and css urls) in the portlet HTML is not yet compliant to the spec. All relative URLs that are encountered in the HTML are re-written by the Portlet Consumer to point directly to the Portlet Producer. This implies that the Producers are available on the web making it very difficult to use producers that are shielded behind a firewall. If you don’t have this restriction or know of an implementation that handles resource URLs via the consumer then the technology is well worth the considerations.