13.3. Configuring Spring

Flow Handlers

The only supported mechanism for bridging a portlet request to Web Flow is a FlowHandler. The PortletFlowController used in Web Flow 1.0 is no longer supported.

The flow handler, similar to the servlet flow handler, provides hooks that can:

  • select the flow to execute

  • pass input parameters to the flow on initialization

  • handle the flow execution outcome

  • handle exceptions

The AbstractFlowHandler class is an implementation of FlowHandler that provides default implementations for these hooks.

In a portlet environment the targeted flow id can not be inferred from the URL and must be defined explicitly in the handler.

public class ViewFlowHandler extends AbstractFlowHandler {
    public String getFlowId() {
        return "view";
    }
}
			

Handler Mappings

Spring Portlet MVC provides a rich set of methods to map portlet requests. Complete documentation is available in the Spring Reference Documentation.

The booking-portlet-mvc sample application uses a PortletModeHandlerMapping to map portlet requests. The sample application only supports view mode, but support for other portlet modes is available. Other modes can be added and point to the same flow as view mode, or any other flow.

<bean id="portletModeHandlerMapping" 
      class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
    <property name="portletModeMap">
        <map>
            <entry key="view">
                <bean class="org.springframework.webflow.samples.booking.ViewFlowHandler" />
            </entry>
        </map>
    </property>
</bean>
			

Flow Handler Adapter

A FlowHandlerAdapter converts the handler mappings to the flow handlers. The flow executor is required as a constructor argument.

<bean id="flowHandlerAdapter" 
      class="org.springframework.webflow.mvc.portlet.FlowHandlerAdapter">
    <constructor-arg ref="flowExecutor" />
</bean>