6.2.4. The portlet.xml Descriptor

The portlet.xml descriptor is the standard portlet descriptor covered by the JSR-168 Portlet Specification. Developers are strongly encouraged to read the JSR-168 Portlet Specification items covering the correct use of this descriptor, as it is only covered briefly in these sections. Normally the portlet.xml descriptor is packaged inside your portlet WAR file, alongside the other descriptors in these sections. The following example is a modified version of the JBoss Portal UserPortlet definition:
<?xml version="1.0" encoding="UTF-8"?>
      <description>Portlet providing user login/logout and profile management</description>
      <display-name>User Portlet</display-name>
         <description>Initialize the portlet with a default page to render</description>
         <title>User portlet</title>
  • <portlet-app>...</portlet-app>
    The <portlet-app> element encapsulates the entire document. Multiple portlets can be specified using the <portlet-app> element.
  • <portlet>...</portlet>
    The <portlet> element defines one portlet that is deployed within this archive.
  • <description>...</description>
    The <description> element is a verbal description of the portlet's function.
  • <portlet-name>...</portlet-name>
    The <portlet-name> element defines the portlet name. It does not have to be the class name.
  • <portlet-class>...</portlet-class>
    The <portlet-class> element defines the Fully Qualified Name (FQN) of the portlet class.
  • <init-param>
    The <init-param> element specifies initialization parameters to create an initial state inside your portlet class. This is usually used in the portlet's init() method, but not necessarily. Unlike a preference, an init-parameter is data that does not change at runtime and does not go into a database. If the value is changed in the descriptor, the change takes immediate effect after re-deploying the portlet. Multiple <init-param> elements can be used.
  • <supports>...</supports>
    The <supports> element declares all of the markup types that a portlet supports. Use the <mime-type> element to declare supported capabilities, for example, if the only outputs are text and HTML, use <mime-type>text/html</mime-type>. Use the <portlet-mode> element to define the supported portlet modes for the portlet. For example, all portlets must support the view portlet mode, which is defined using <portlet-mode>view</portlet-mode>.
  • <supported-locale>...</supported-locale>
    The <supported-locale> elements advertise the supported locales for the portlet. Use multiple <supported-locale> elements to specify multiple locales.
  • <resource-bundle>...</resource-bundle>
    The <resource-bundle> element specifies the resource bundle that contains the localized information for the specified locales.
  • <portlet-info>
    The <title> element defines the portlet's title, which is displayed in the portlet window's title bar.

The portlet.xml Example

This portlet.xml example is not a replacement for what is covered in the JSR-168 Portlet Specification.