13.2. Configuring web.xml and portlet.xml

The configuration for a portlet depends on the portlet container used. The sample applications, included with Web Flow, are both configured to use Apache Pluto, the JSR-168 reference implementation.

In general, the configuration requires adding a servlet mapping in the web.xml file to dispatch request to the portlet container.

<servlet>
    <servlet-name>swf-booking-mvc</servlet-name>
    <servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>
    <init-param>
        <param-name>portlet-name</param-name>
        <param-value>swf-booking-mvc</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>swf-booking-mvc</servlet-name>
    <url-pattern>/PlutoInvoker/swf-booking-mvc</url-pattern>
</servlet-mapping>
		

The portlet.xml configuration is a standard portlet configuration. The portlet-class needs to be set along with a pair of init-params. Setting the expiration-cache to 0 is recommended to force Web Flow to always render a fresh view.

<portlet>
    ...
    <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
    <init-param>
        <name>contextConfigLocation</name>
        <value>/WEB-INF/web-application-config.xml</value>
    </init-param>
    <init-param>
        <name>viewRendererUrl</name>
        <value>/WEB-INF/servlet/view</value>
    </init-param>
    <expiration-cache>0</expiration-cache>
    ...
</portlet>