Deployment descriptors
Each portlet application requires two deployment descriptors:
The following topics describe the deployment descriptors of a portlet application:
- The portlet deployment descriptor provides the portal server with information about the portlet resources in the application, including configuration, support characteristics, and localized titles. The portal server uses this information to provide services for the portlet. For example, if a portlet registers its support for help and edit mode in the portlet deployment descriptor, the portal server renders icons to allow the user to invoke the portlet's help and edit pages. This file is always named portlet.xml.
- The web application descriptor provides the application server with information about the web resources in the application. This file is always named web.xml. The format of this file is described in the Deployment Descriptor chapter of the Servlet Specification.
Web application deployment descriptor
This section describes the required elements of the web.xml for IBM and standard portlets. For more information about the web application deployment descriptor, see the Java Servlet Specification Version 2.3.
Web application descriptor for standard portletsAs described in the Java Portlet Specification, a portlet application is an extended web application and therefore has a servlet context. The portlet context uses most of its functionality from the servlet context of the portlet application. Since the web.xml is a mandatory item in a J2EE web ARchive, you should make sure portlet application includes a web.xml in its WAR file that conforms to Version 2.3 or a later version of the Java Servlet Specification. This ensures that the portlet application is compatible with other portal server implementations as well as WebSphere Portal. The web.xml should contain, at a minimum, the <web-app/> and <display-name/> elements. You can also include context-wide parameters using the <init-param> element. Refer to the Java Servlet Specification Version for more information about the structure of the web application deployment descriptor.
IBM web application descriptor
As with other servlets following the J2EE model, IBM portlets are packaged as WAR or EAR files with a web application deployment descriptor (web.xml). This descriptor defines each portlet as a servlet within the web application, including unique identifiers for each portlet, the portlet class, and initialization parameters.
Table 1. The href attribute in the portlet.xml and web.xml filesThe definition of the servlets in the web.xml must be in the same order as the definition of portlets in the portlet.xml. The servlet identifier must be referenced by the portlet deployment descriptor, using the href attribute of the <portlet> tag. As shown in the following table, the href attribute indicates the path of the web application descriptor in the WAR file appended by the servlet ID as the anchor.
portlet.xml web.xml <portlet id="Portlet_1" href="WEB-INF/web.xml#Servlet_1"> <portlet-name>Mail</portlet-name> ... </portlet>
<servlet id="Servlet_1"> <servlet-name>MailPortlet</servlet-name> ... </servlet> <portlet id="Portlet_2" href="WEB-INF/web.xml#Servlet_2"> <portlet-name>Calendar</portlet-name> ... </portlet>
<servlet id="Servlet_2"> <servlet-name>CalendarPortlet</servlet-name> ... </servlet>
Portlet deployment descriptor
This section describes the portlet.xml for standard and IBM portlets.Guidelines for portlet application identifiers
- The elements and structure of the IBM portlet.xml is provided in this topic.
- For information about the portlet deployment descriptor for the standard portlet API, see the Java Portlet Specification.
The identifiers of portlet applications must identify them unambiguously in the area of their usage, which could be worldwide. The same is true for concrete portlet applications for IBM portlets. To make this possible, follow these guidelines.
Portlet identifiers must be unique within the application.
- Include the portlet's namespace in the identifier, using the same format used for the Java packages
- Add some portlet application specific description
- Add some arbitrary characters to guarantee uniqueness within the namespace, for example:
com.ibm.wps.samplet.mail.4969
- For IBM portlets, add suffixes for the corresponding concrete portlet applications, for example:
com.ibm.wps.samplet.mail.4969.1Standard portlet deployment descriptor
In the Java Portlet Specification, the portlet descriptor is in the format of an XML Schema. Since the portlet is not a servlet, the portlet descriptor does not reference a corresponding servlet ID in the web.xml. The top level element is the <portlet-app/> which contains one or more <portlet/> definitions. Portlet specific initialization parameters are stored in the portlet.xml by using the <init-param/> element and are obtained from the PortletConfig object provided during initialization.
IBM portlet deployment descriptorThe structure of the IBM portlet deployment descriptor is defined by a DTD, which is located at wps.war/dtd/portlet_1.1.dtd.
Table 2. The href attribute in the portlet tag and the concrete portlet tagFor IBM portlets, each concrete portlet definition indicates its parent portlet using the href attribute of the <concrete-portlet> tag. As shown in the following table, the href attribute indicates the portlet ID as an anchor.
Portlet tag Concrete portlet tag <portlet id="Portlet_1" href="WEB-INF/web.xml#Servlet_1"> <portlet-name>Mail</portlet-name> ... </portlet>
<concrete-portlet href="#Portlet_1"> <portlet-name>Mail Box</portlet-name> ... </concrete-portlet> <portlet id="Portlet_2" href="WEB-INF/web.xml#Servlet_2"> <portlet-name>Calendar</portlet-name> ... </portlet>
<concrete-portlet href="#Portlet_2"> <portlet-name>Group calendar</portlet-name> ... </concrete-portlet>
Reserved parameter names
This section describes parameters that can be set for portlets. There are two types of parameters:
Configuration parametersThese are parameters for a portlet that can be changed only by an administrator. They are defined in the file portlet.xml using either the <config-param/> elements (for IBM portlets) or the <preferences/> element marked as read-only (for standard portlets).
Initialization parametersThese parameters are set during deployment. For standard portlets, they are set by the <init-param/> element in the portlet.xml. For IBM portlets, they are set by the <init-param/> element in the web.xml.
The following parameters can be set as configuration parameters in IBM portlets or initialization parameters in standard portlets:redirect.action.without.session = (false)
Set this parameter to true to enforce a redirect after an action on anonymous pages for this portlet.
wps.enforce.redirect = (false)Set this parameter to true if portlet requires a redirect for a portlet action. The advantage of sending a redirect is that the URL will change to hold the complete state in the URL such that the resulting URL is present in the browser and can be bookmarked. The downside is that the additional request generates more load on the server. The portlet does not need the redirect after action if it does not set any public or private render parameters in processAction or processEvent.
wps.markupThis is an initialization parameter in standard portlets to define the supported markup types for the portlet. Use it to differentiate between markup types, such as HTML and cHTML, that use the same MIME type.
com.ibm.portal.automaximizeSet this parameter to true to automatically maximize the portlet when the user switches from view mode to any of the other supported modes. The default is false.
wps.multiple.action.executionSet this parameter to true to enable the user to execute the same action URL several times.
The following parameters can be set as configuration parameters in IBM portlets or read-only preferences in standard portlets:parallel = (false)
When you set this parameter to true, you indicate that the portlet can be rendered in parallel with other portlets on the page. The default is false.
com.ibm.portal.pagecontext.enable = (false)When you set this parameter to true, you indicate that the portlet can retrieve task properties. This parameter is used by task processing portlets. The default is false.
Container run time options
The portal defines container run time options which can be used by portlets that conform to the Java Portlet Specification 2.0 (JSR286). You set these parameters by using the <container-runtime-option> element in the portlet.xml.
com.ibm.portal.public.sessionSet this parameter to true to allow session creation for anonymous users for this particular portlet. Example:
<container-runtime-option> <name>com.ibm.portal.public.session</name> <value>true</value> </container-runtime-option>
Parent
Portlet development reference
Markup guidelines
Access the portlet session on the anonymous page
IBM portlet DTD tag reference
JSP tags for standard portlets
JSP tags for IBM portlets
Drag and drop JSP tags reference
Handling and visibility of request parameters in portlets
Detailed descriptions of the Struts WML tags
Application extension registry