Expert Spring MVC and Web Flow

(Dana P.) #1

Table 12-2.Provided Adapters for ExternalContext


Adapter Class Description


org.springframework.webflow.context. Provides information about a request into Spring
portlet.PortletExternalContext Web Flow from a JSR-168 Portlet environment.


org.springframework.webflow.context. Provides information about a request into Spring
servlet.ServletExternalContext Web Flow from within an HTTP Servlet environment.
A StrutsExternalContextsubclass exists for integration
with the Struts framework.


org.springframework.webflow.manager. Provides information about a request into Spring Web
jsf.JsfExternalContext Flow from JavaServer Faces ( JSF).


After processing an external event, the FlowExecutionManagerreturns a ViewSelection.
A ViewSelection is a ValueObject (http://java.sun.com/blueprints/corej2eepatterns/
Patterns/TransferObject.html) that selects a view to be rendered after event processing
and any model data to be rendered with it. Refer to Table 12-3.


Table 12-3.Overview of org.springframework.webflow.ViewSelection


Property Description


viewName Logical name of the View.


model Map containing data that may be rendered by the view.


redirect Boolean value indicating whether the view should trigger a redirect.


You may wonder why ViewSelectionis a class but ExternalContextis an interface.
ExternalContextis a contract for behavior, but a ViewSelectionis a concrete object—a value
object. Spring Web Flow does not make assumptions about the environment it is executing
within, so it cannot determine which implementationof ExternalContextto instantiate. It is
up to the external system to instantiate an appropriate ExternalContextwhen calling into
Spring Web Flow.Similarly, Spring Web Flow makes logical view selections when executing
flows but does not care for response rendering. It is also the responsibility of the calling sys-
tem to locate the appropriate view template to render using a returned ViewSelection as a
pointer. This is why a ViewSelectionand not Viewis returned.


The FlowExecutionManager


As mentioned in the previous section, the FlowExecutionManageris responsible for managing the
creation and resuming of FlowExecutions. It defines two methods, as shown in Listing 12-12.


Listing 12-12.org.springframework.webflow.manager.FlowExecutionManager


public interface FlowExecutionManager {
public ViewSelection launch (
String flowId,
......
) throws FlowException;


CHAPTER 12 ■ADVANCED SPRING WEB FLOW 347
Free download pdf