3.1.1.1.2. Application descriptors

GateIn 3.5 requires certain descriptors to be included in a portlet WAR file. These descriptors are defined by the Java EE (web.xml) and Portlet Specification (portlet.xml).

Below is an example of the WEB-INF/portlet.xml file. This file must adhere to its definition in the JSR-286 Portlet Specification. More than one portlet can be defined in this file:


<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd 
                                         http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
   version="2.0">
(1)    <portlet>
        <portlet-name>SimplestHelloWorldPortlet</portlet-name>
(2)        <portlet-class>
            org.gatein.portal.examples.portlets.SimplestHelloWorldPortlet
        </portlet-class>
(3)        <supports>
            <mime-type>text/html</mime-type>
        </supports>
(4)        <portlet-info>
            <title>Simplest Hello World Portlet</title>
        </portlet-info>
    </portlet>
</portlet-app>

1

Define the portlet name. It does not have to be the class name.

2

The Fully Qualified Name (FQN) of your portlet class must be declared here.

3

The <supports> element declares all of the markup types that a portlet supports in the render method. This is accomplished via the <mime-type> element, which is required for every portlet.

The declared MIME types must match the capability of the portlet. It allows administrators to pair which modes and window states are supported for each markup type.

This does not have to be declared as all portlets must support the view portlet mode.

Use the <mime-type> element to define which markup type is supported by the portlet. In the example above, this is text/html. This section tells the portal to only output HTML.

4

When rendered, the portlet's title is displayed as the header in the portlet window, unless it is overridden programmatically. In the example above, the title would be Simplest Hello World Portlet .

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus