JBoss.org Community Documentation Page creation

Any JSP page can contain portlets, the only requirement to make this possible is to have the page located in Simple Portal's WAR file and to use the portal tag library.

Let's look at a minimal portal page using the portal tag library:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/portal.tld" prefix="portal" %>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <title>Simple portal page</title>
       <portal:portlet name="JSPPortlet" applicationName="samples-jsp-portlet">

Example 3.1. Minimal portal page

The portal tag library declaration enables the JSP compiler to know about the existence of the simple portal. It is declared by the JSP declaration <%@ taglib uri="/WEB-INF/portal.tld" prefix="portal" %> and it binds the portal tag library to the portal namespace.

The interesting part of the markup is the portal:page element and its children. The page tag defines a logical scope that is used by Simple Portal to generate markup:

  • It defines a container for a set of portlets.
  • It defines the page area that will be replaced entirely by a maximized portlet markup (when the maximized window state is requested).
  • It defines a scope for the coordination features.

Currently, only one portal page can be specified per JSP file but this should be extended to several portal pages per JSP file in future versions of JBoss Portlet Container.

Access to portlet information within a portal page is done by defining a reference to the portlet using the portlet tag. The mandatory attributes for this tag are name and applicationName that are used to locate the deployed portlet. The applicationName refers to the name of the WAR file containing your portlet application without the extension .war and the name attribute refers to the portlet name as declared by the portlet-name element in the portlet.xml file of your portlet application WAR file. Similarly to the page tag, the portlet tag does not produce any markup but rather makes your portlet available to Simple Portal.

The portlet markup is output using the portletmarkup tag. This tag is replaced by the referenced portlet markup (without any decoration) when the page is rendered.