Portal Guide
CHAPTER 16
This chapter describes techniques for using portlets with JSP pages. It covers the following topics:
exteNd Director provides the following tag libraries for using portlets with JSP pages:
Tag library |
Description |
---|---|
PortalTag.tld |
Provides custom tags for handling render and action URL requests, rendering portlet content, and styling portlet content on a JSP page. For more information, see Adding portlets to JSP pages using custom tags. |
portlet.tld |
Implements the standard portlet tags specified by Java Portlet 1.0. For more information, see Standard portlet tags. |
exteNd Director provides the following custom tags in WEB-INF\tag\PortalTag.tld for displaying portlets within JSP pages:
With these tags, you can add portlets to JSP pages using one or more of the following techniques:
Add unique instances of registered portlets to a JSP page. In this case, each portlet instance has a unique registration ID. See Adding unique instances of portlets to a JSP page.
Add multiple instances of the same registered portlet to a JSP page. In this case, each instance of the portlet has the same registration ID and requires a unique namespace. See Adding multiple instances of the same portlet to a JSP page.
Add pageflow portlets to a JSP page. See Adding pageflow portlets to a JSP page.
NOTE: The registration ID is the name you give a registered instance of a portlet, as described in Procedure for registering a portlet.
For information about the syntax of custom portlet tags in PortalTag.tld, see Portal Tag Library.
To add unique instances of registered portlets to a JSP page:
Add the tag library directive for PortalTag.tld to the top of your JSP page:
<%@ taglib uri="/portal" prefix="portal" %>
This directive makes the tags described in the PortalTag.tld file available to the page.
Add the handlePortletAction tag under the tag library directive and before the <html> section:
<%@ taglib uri="/portal" prefix="portal" %> <portal:handlePortletAction />
Add the getThemeLink tag in the <head> section:
<%@ taglib uri="/portal" prefix="portal" %> <portal:handlePortletAction /> <html> <head> <portal:getThemeLink /> </head>
Add renderPortlet tags for each portlet you want to display on the page.
Here's an example of a JSP page that renders the content of two registered portlets: StockPortfolio and StockQuotePortlet:
<%@ taglib uri="/portal" prefix="portal" %> <portal:handlePortletAction /> <html> <head> <portal:getThemeLink /> </head> <body> <table> <tr> <td>Stock Information Page</td> </tr> <tr> <td><portal:renderPortlet registrationID="StockPortfolio" /></td> </tr> <tr> <td><portal:renderPortlet registrationID="StockQuotePortlet" /></td> </tr> </table> </body> </html>
To add multiple instances of the same registered portlet to a JSP page:
Follow the steps in the procedure Adding unique instances of portlets to a JSP page.
Use a renderPortlet tag for each instance of the same portlet.
In each renderPortlet tag, set the pageNamespace attribute to a unique string.
NOTE: The pageNamespace attribute is used to differentiate portlets with identical registration IDs that reside on the same pageand to allow each portlet to maintain its own session state.
Here's an example of a JSP page that renders the content of three instances of the same registered portlet:
<%@ taglib uri="/portal" prefix="portal" %> <portal:handlePortletAction /> <html> <head> <portal:getThemeLink /> </head> <body> <table> <tr> <td>Stock Portfolio 401K</td> <td>Stock Portfolio Roth IRA</td> <td>Stock Portfolio SEP IRA</td> </tr> <tr> <td>portal:renderPortlet registrationID="StockPortfolio" pageNamespace="401K" /></td> <td>portal:renderPortlet registrationID="StockPortfolio" pageNamespace="Roth" /></td> <td>portal:renderPortlet registrationID="StockPortfolio" pageNamespace="SEP" /></td> </tr> </table> </body> </html>
To add pageflow portlets to a JSP page:
Follow the steps in the procedure Adding unique instances of portlets to a JSP page or Adding multiple instances of the same portlet to a JSP page.
Add the following namespaces in the <html> element of the page:
<%@ taglib uri="/portal" prefix="portal" %> <portal:handlePortletAction /> <html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"> <head> <portal:getThemeLink /> </head> <body> <table> <tr> <td>Human Resources: Benefits Data</td> </tr> <tr> <td><portal:renderPortlet registrationID="MyHRDatabasePageflow" /></td> </tr> </table> </body> </html>
exteNd Director implements the standard portlet tags specified by Java Portlet 1.0. The standard Portlet Tag Library enables JSPs that are included from portlets to have direct access to portlet-specific elements and portlet functionality.
The standard portlet tags are:
To use standard portlet tags, add the following tag library directive to the top of your JSP page:
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
For more information about the standard Portlet Tag Library, refer to the Java Portlet 1.0 specification, available from the Java Community Process Web site at:
http://jcp.org/aboutJava/communityprocess/final/jsr168/index.html
Copyright © 2004 Novell, Inc. All rights reserved. Copyright © 1997, 1998, 1999, 2000, 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved. more ...