diff --git a/src/reference/actions.xml b/src/reference/actions.xml index bf23ef26..aa29a2df 100644 --- a/src/reference/actions.xml +++ b/src/reference/actions.xml @@ -1,10 +1,14 @@ - + Executing actions - + Introduction This chapter shows you how to use the action-state element to control the execution of an action at a point within a flow. @@ -12,52 +16,52 @@ Finally, several examples of invoking actions from the various points possible within a flow will be discussed. - + Defining action states Use the action-state element when you wish to invoke an action, then transition to another state based on the action's outcome: - - - + + + ]]> - + The full example below illustrates a interview flow that uses the action-state above to determine if more answers are needed to complete the interview: + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/webflow + http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - ]]> - + - + Defining decision states Use the decision-state element as an alternative to the action-state to make a routing decision using a convenient if/else syntax. @@ -65,11 +69,11 @@ - + ]]> - + Action outcome event mappings Actions often invoke methods on plain Java objects. @@ -77,7 +81,7 @@ Since transitions are triggered by events, a method return value must first be mapped to an Event object. The following table describes how common return value types are mapped to Event objects: - +
Action method return value to event id mappings @@ -105,7 +109,7 @@ any other type success - +
@@ -113,13 +117,13 @@ - - - + + + ]]> - +
- + Action implementations While writing action code as POJO logic is the most common, there are several other action implementation options. @@ -132,26 +136,26 @@ Invoking a POJO action ]]> - +]]> + Invoking a custom Action implementation ]]> - +]]> + @@ -159,24 +163,24 @@ public class CustomAction implements Action { Invoking a MultiAction implementation -]]> - +]]> + - + Action exceptions Actions often invoke services that encapsulate complex business logic. @@ -189,21 +193,21 @@ public class CustomMultiAction extends MultiAction { The result is treated as a flow event which the calling flow can then respond to. ]]> - +]]> + @@ -214,144 +218,144 @@ public class BookingAction { The MultiAction requires its action methods to be of the signature Event ${methodName}(RequestContext), providing stronger type safety, while a POJO action allows for more freedom. ]]> - +]]> + - + - + Other Action execution examples - + on-start The following example shows an action that creates a new Booking object by invoking a method on a service: + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/webflow + http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> - + - - - + + + ]]> - + on-entry The following example shows a state entry action that sets the special fragments variable that causes the view-state to render a partial fragment of its view: - - - + + + ]]> - + on-exit The following example shows a state exit action that releases a lock on a record being edited: - - - - - - - - - + + + + + + + + + ]]> - + on-end The following example shows the equivalent object locking behavior using flow start and end actions: + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/webflow + http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> - + - - - + + + - - - - - + + + + + + + + + - - - - ]]> - + on-render The following example shows a render action that loads a list of hotels to display before the view is rendered: - - - - - - + + + + + + ]]> - + on-transition The following example shows a transition action adds a subflow outcome event attribute to a collection: - - - + + + ]]> - - + + Named actions The following example shows how to execute a chain of actions in an action-state. @@ -359,13 +363,13 @@ public class BookingAction extends MultiAction { - - - - - - - + + + + + + + ]]> @@ -373,7 +377,7 @@ public class BookingAction extends MultiAction { completes successfully. - + Streaming actions Sometimes an Action needs to stream a custom response back to the client. @@ -383,45 +387,45 @@ public class BookingAction extends MultiAction { - - - + + + ]]> - + In this example, when the print event is raised the flow will call the printBoardingPassAction. The action will render the PDF then mark the response as complete. - + Handling File Uploads - Another common task is to use Web Flow to handle multipart file uploads in combination with Spring MVC's - MultipartResolver. Once the resolver is set up correctly as described here and the submitting - HTML form is configured with enctype="multipart/form-data", you can easily handle the file upload in a - transition action. + Another common task is to use Web Flow to handle multipart file uploads in combination with Spring MVC's + MultipartResolver. Once the resolver is set up correctly as described here and the submitting + HTML form is configured with enctype="multipart/form-data", you can easily handle the file upload in a + transition action. Note that the File Upload example below below is not relevant when using Web Flow with JSF. - Check the documentation of your JSF component library to see what file upload components it provides. + Check the documentation of your JSF component library to see what file upload components it provides. - Given a form such as: + Given a form such as: - Select file: - + Select file: + ]]> @@ -433,16 +437,16 @@ package org.springframework.webflow.samples.booking; import org.springframework.web.multipart.MultipartFile; public class FileUploadHandler { - - private transient MultipartFile file; - - public void processFile() { - //Do something with the MultipartFile here - } - public void setFile(MultipartFile file) { - this.file = file; - } + private transient MultipartFile file; + + public void processFile() { + //Do something with the MultipartFile here + } + + public void setFile(MultipartFile file) { + this.file = file; + } }]]> @@ -450,18 +454,18 @@ public class FileUploadHandler { - - - - - + + + + + ]]> - The MultipartFile will be bound to the FileUploadHandler bean as - part of the normal form binding process so that it will be available to process during the + The MultipartFile will be bound to the FileUploadHandler bean as + part of the normal form binding process so that it will be available to process during the execution of the transition action. - +
diff --git a/src/reference/defining-flows.xml b/src/reference/defining-flows.xml index 0666658c..1e8bcb88 100644 --- a/src/reference/defining-flows.xml +++ b/src/reference/defining-flows.xml @@ -1,10 +1,14 @@ - + Defining Flows - + Introduction This chapter begins the Users Section. @@ -12,11 +16,11 @@ By the end of this chapter you should have a good understanding of language constructs, and be capable of authoring a flow definition. - + What is a flow? A flow encapsulates a reusable sequence of steps that can execute in different contexts. - Below is a Garrett Information Architecture diagram illustrating a reference to a flow that encapsulates the steps of a hotel booking process: + Below is a Garrett Information Architecture diagram illustrating a reference to a flow that encapsulates the steps of a hotel booking process: @@ -30,7 +34,7 @@ - + What is the makeup of a typical flow? In Spring Web Flow, a flow consists of a series of steps called "states". @@ -51,18 +55,18 @@ Flow diagram - + - + How are flows authored? Flows are authored by web application developers using a simple XML-based flow definition language. The next steps of this guide will walk you through the elements of this language. - + Essential language elements - + flow Every flow begins with the following root element: @@ -81,7 +85,7 @@ The first state defined becomes the flow's starting point. - + view-state Use the view-state element to define a step of the flow that renders a view: @@ -91,11 +95,11 @@ By convention, a view-state maps its id to a view template in the directory where the flow is located. - For example, the state above might render /WEB-INF/hotels/booking/enterBookingDetails.xhtml + For example, the state above might render /WEB-INF/hotels/booking/enterBookingDetails.xhtml if the flow itself was located in the /WEB-INF/hotels/booking directory. - + transition Use the transition element to handle events that occur within a state: @@ -109,7 +113,7 @@ These transitions drive view navigations. - + end-state Use the end-state element to define a flow outcome: @@ -121,9 +125,9 @@ When a flow transitions to a end-state it terminates and the outcome is returned. - + Checkpoint: Essential language elements - + With the three elements view-state, transition, and end-state, you can quickly express your view navigation logic. Teams often do this before adding flow behaviors so they can focus on developing the user interface of the application with end users first. Below is a sample flow that implements its view navigation logic using these elements: @@ -137,22 +141,22 @@ - + - + - -]]> + +]]> - + Actions Most flows need to express more than just view navigation logic. @@ -167,13 +171,13 @@ On transition execution On state exit On flow end - + Actions are defined using a concise expression language. Spring Web Flow uses the Unified EL by default. The next few sections will cover the essential language elements for defining actions. - + evaluate The action element you will use most often is the evaluate element. @@ -182,9 +186,9 @@ For example: ]]> +]]> - + Assigning an evaluate result If the expression returns a value, that value can be saved in the flow's data model called flowScope: @@ -193,7 +197,7 @@ ]]> - + Converting an evaluate result If the expression returns a value that may need to be converted, specify the desired type using the result-type attribute: @@ -204,9 +208,9 @@ - + Checkpoint: flow actions - + Now review the sample booking flow with actions added: - - + - + - -]]> + +]]> This flow now creates a Booking object in flow scope when it starts. @@ -244,7 +248,7 @@ - + Input/Output Mapping Each flow has a well-defined input/output contract. @@ -259,11 +263,11 @@ FlowOutcome flowId(Map inputAttributes);]]> getOutputAttributes(); }]]> - + input Use the input element to declare a flow input attribute: @@ -275,7 +279,7 @@ public interface FlowOutcome { Input values are saved in flow scope under the name of the attribute. For example, the input above would be saved under the name hotelId. - + Declaring an input type Use the type attribute to declare the input attribute's type: @@ -287,7 +291,7 @@ public interface FlowOutcome { If an input value does not match the declared type, a type conversion will be attempted. - + Assigning an input value Use the value attribute to specify an expression to assign the input value to: @@ -299,7 +303,7 @@ public interface FlowOutcome { If the expression's value type can be determined, that metadata will be used for type coersion if no type attribute is specified. - + Marking an input as required Use the required attribute to enforce the input is not null or empty: @@ -309,7 +313,7 @@ public interface FlowOutcome { - + output Use the output element to declare a flow output attribute. @@ -317,26 +321,26 @@ public interface FlowOutcome { - + ]]> Output values are obtained from flow scope under the name of the attribute. For example, the output above would be assigned the value of the bookingId variable. - + Specifying the source of an output value Use the value attribute to denote a specific output value expression: ]]> +]]> - + Checkpoint: input/output mapping - + Now review the sample booking flow with input/output mapping: - - + - + - -]]> - + +]]> + The flow now accepts a hotelId input attribute and returns a bookingId output attribute when a new booking is confirmed. - + - + Variables A flow may declare one or more instance variables. These variables are allocated when the flow starts. Any @Autowired transient references the variable holds are also rewired when the flow resumes. - + var Use the var element to declare a flow variable: @@ -396,12 +400,12 @@ public interface FlowOutcome { - + Calling subflows A flow may call another flow as a subflow. The flow will wait until the subflow returns, then respond to the subflow outcome. - + subflow-state Use the subflow-state element to call another flow as a subflow: @@ -409,7 +413,7 @@ public interface FlowOutcome { - + ]]> @@ -418,7 +422,7 @@ public interface FlowOutcome { The above example calls the createGuest flow, then waits for it to return. When the flow returns with a guestCreated outcome, the new guest is added to the booking's guest list. - + Passing a subflow input Use the input element to pass input to the subflow: @@ -430,24 +434,24 @@ public interface FlowOutcome { ]]> - + Mapping subflow output Simply refer to a subflow output attribute by its name within a outcome transition: - + ]]> In the above example, guest is the name of an output attribute returned by the guestCreated outcome. - + - + Checkpoint: calling subflows - + Now review the sample booking flow calling a subflow: - @@ -476,22 +480,22 @@ public interface FlowOutcome { - + - + - -]]> + +]]> The flow now calls a createGuest subflow to add a new guest to the guest list. - - + + diff --git a/src/reference/el.xml b/src/reference/el.xml index abda5a6a..3a608627 100644 --- a/src/reference/el.xml +++ b/src/reference/el.xml @@ -1,10 +1,14 @@ - + Expression Language (EL) - + Introduction Web Flow uses EL to access its data model and to invoke actions. @@ -23,12 +27,12 @@ EL is also used to bind form parameters to model objects and reversely to render formatted form fields from the properties of a model object. That however does not apply when using Web Flow with JSF in which case the standard JSF component lifecyle applies. - + Expression types An important concept to understand is there are two types of expressions in Web Flow: standard expressions and template expressions. - + Standard Expressions The first and most common type of expression is the standard expression. @@ -43,10 +47,10 @@ If you attempt to enclose this expression in a special delimiter like #{} you will get an IllegalArgumentException. In this context the delimiter is seen as redundant. The only acceptable value for the expression attribute is an single expression string. - + - - Template expressions + + Template expressions The second type of expression is a template expression. A template expression allows mixing of literal text with one or more standard expressions. @@ -70,25 +74,25 @@ - + EL Implementations - + Spring EL - Starting with version 2.1 Web Flow uses the Spring Expression Language (Spring EL). + Starting with version 2.1 Web Flow uses the Spring Expression Language (Spring EL). Spring EL was created to provide is a single, well-supported expression language for use across all the products in the Spring portfolio. It is distributed as a separate jar org.springframework.expression in the Spring Framework. Existing applications will need to remove dependencies on org.jboss.el or org.ognl and use org.springframework.expression instead. See the section below on EL Portability for other notes on upgrading. - + Unified EL - In Web Flow 2.0 Unified EL was the default expression language with jboss-el as the implementation. - Use of Unified EL also implies a dependency on el-api although that is typically provided by your web container. + In Web Flow 2.0 Unified EL was the default expression language with jboss-el as the implementation. + Use of Unified EL also implies a dependency on el-api although that is typically provided by your web container. Tomcat 6 includes it, for example. - Spring EL is the default and recommended expression language to use. + Spring EL is the default and recommended expression language to use. However it is possible to replace it with Unified EL if you wish to do so. You need the following Spring configuration to plug in the WebFlowELExpressionParser to the flow-builder-services: - + OGNL - OGNL is the third supported expression language. + OGNL is the third supported expression language. OGNL is the EL most familiar to Web Flow version 1.0 users. - Please refer to the OGNL language guide for specifics on its EL syntax. - If you wish to use OGNL this is the Spring configuration necessary to plug it in: + Please refer to the OGNL language guide for specifics on its EL syntax. + If you wish to use OGNL this is the Spring configuration necessary to plug it in: @@ -140,7 +144,7 @@ - + EL portability In general, you will find Spring EL, Unified EL and OGNL to have a very similar syntax. @@ -162,10 +166,10 @@ - For more information on Spring EL syntax please refer to the Language Reference section in the Spring Documentation. + For more information on Spring EL syntax please refer to the Language Reference section in the Spring Documentation. - + Special EL variables There are several implicit variables you may reference from within a flow. @@ -176,7 +180,7 @@ Variables referring to data scopes (flowScope, viewScope, requestScope, etc.) should only be used when assigning a new variable to one of the scopes. - For example when assigning the result of the call to bookingService.findHotels(searchCriteria) to a new variable called "hotels" you must prefix it with a scope variable in order to let Web Flow know where you want it stored: + For example when assigning the result of the call to bookingService.findHotels(searchCriteria) to a new variable called "hotels" you must prefix it with a scope variable in order to let Web Flow know where you want it stored: @@ -188,7 +192,7 @@ - + ]]> However when setting an existing variable such as "searchCriteria" in the example below, you reference the variable directly without prefixing it with any scope variables: @@ -210,23 +214,23 @@ The following is the list of implicit variables you can reference within a flow definition: - + flowScope Use flowScope to assign a flow variable. - Flow scope gets allocated when a flow starts and destroyed when the flow ends. With the default + Flow scope gets allocated when a flow starts and destroyed when the flow ends. With the default implementation, any objects stored in flow scope need to be Serializable. ]]> - + viewScope Use viewScope to assign a view variable. View scope gets allocated when a view-state enters and destroyed when the state exits. - View scope is only referenceable from within a view-state. With the + View scope is only referenceable from within a view-state. With the default implementation, any objects stored in view scope need to be Serializable. ]]> - - + + requestScope Use requestScope to assign a request variable. @@ -246,31 +250,31 @@ ]]> - + flashScope Use flashScope to assign a flash variable. - Flash scope gets allocated when a flow starts, cleared after every view render, and destroyed when the + Flash scope gets allocated when a flow starts, cleared after every view render, and destroyed when the flow ends. With the default implementation, any objects stored in flash scope need to be Serializable. ]]> +]]> - + conversationScope Use conversationScope to assign a conversation variable. Conversation scope gets allocated when a top-level flow starts and destroyed when the top-level flow ends. - Conversation scope is shared by a top-level flow and all of its subflows. With the default - implementation, conversation scoped objects are stored in the HTTP session and should generally be + Conversation scope is shared by a top-level flow and all of its subflows. With the default + implementation, conversation scoped objects are stored in the HTTP session and should generally be Serializable to account for typical session replication. ]]> - + requestParameters Use requestParameters to access a client request parameter: @@ -279,7 +283,7 @@ ]]> - + currentEvent Use currentEvent to access attributes of the current Event: @@ -288,17 +292,17 @@ ]]> - + currentUser Use currentUser to access the authenticated Principal: ]]> - + messageContext Use messageContext to access a context for retrieving and creating flow execution messages, including error and success messages. @@ -308,7 +312,7 @@ ]]> - + resourceBundle Use resourceBundle to access a message resource. @@ -317,39 +321,39 @@ ]]> - + flowRequestContext Use flowRequestContext to access the RequestContext API, which is a representation of the current flow request. See the API Javadocs for more information. - - + + flowExecutionContext Use flowExecutionContext to access the FlowExecutionContext API, which is a representation of the current flow state. See the API Javadocs for more information. - - + + flowExecutionUrl Use flowExecutionUrl to access the context-relative URI for the current flow execution view-state. - - + + externalContext Use externalContext to access the client environment, including user session attributes. See the ExternalContext API JavaDocs for more information. ]]> - + Scope searching algorithm As mentioned earlier in this section when assigning a variable in one of the flow scopes, referencing that scope is required. diff --git a/src/reference/flow-definition-field-mappings.xml b/src/reference/flow-definition-field-mappings.xml index 778fcd7f..0915d81b 100644 --- a/src/reference/flow-definition-field-mappings.xml +++ b/src/reference/flow-definition-field-mappings.xml @@ -1,16 +1,20 @@ - + Flow Definition Language 1.0 to 2.0 Mappings The flow definition language has changed since the 1.0 release. This is a listing of the language elements in the 1.0 release, and how they map to elements in the 2.0 release. While most of the changes are semantic, there are a few structural changes. - Please see the upgrade guide for more details about changes between Web Flow 1.0 and 2.0. + Please see the upgrade guide for more details about changes between Web Flow 1.0 and 2.0. - +
Mappings @@ -69,8 +73,6 @@ * - - action-state @@ -95,8 +97,6 @@ parent - - argument @@ -118,8 +118,6 @@ parameter-type - - attribute @@ -152,8 +150,6 @@ value - - attribute-mapper @@ -176,8 +172,6 @@ now subflow-attribute-mapper attribute on subflow-state - - bean-action @@ -213,8 +207,6 @@ * - - decision-state @@ -239,8 +231,6 @@ parent - - end-actions @@ -249,8 +239,6 @@ on-end - - end-state @@ -291,8 +279,6 @@ commit - - entry-actions @@ -301,8 +287,6 @@ on-entry - - evaluate-action @@ -346,8 +330,6 @@ result-type - - evaluation-result @@ -356,7 +338,7 @@ * - use <evaluate result="..." /> + use <evaluate result="..." /> @@ -375,8 +357,6 @@ * - - exception-handler @@ -393,8 +373,6 @@ bean - - exit-actions @@ -403,8 +381,6 @@ on-exit - - flow @@ -437,8 +413,6 @@ abstract - - global-transitions @@ -447,8 +421,6 @@ global-transitions - - if @@ -481,8 +453,6 @@ else - - import @@ -499,8 +469,6 @@ resource - - inline-flow @@ -520,8 +488,6 @@ * - - input-attribute @@ -573,8 +539,6 @@ value - - input-mapper @@ -586,8 +550,6 @@ inputs can be in flows and subflows directly - - mapping @@ -656,8 +618,6 @@ required - - method-argument @@ -669,8 +629,6 @@ use <evaluate expression="func(arg1, arg2, ...)"/> - - method-result @@ -698,8 +656,6 @@ * - - output-attribute @@ -751,8 +707,6 @@ value - - output-mapper @@ -764,8 +718,6 @@ output can be in flows and subflows directly - - render-actions @@ -774,8 +726,6 @@ on-render - - set @@ -830,8 +780,6 @@ type - - start-actions @@ -840,8 +788,6 @@ on-start - - start-state @@ -861,8 +807,6 @@ * - - subflow-state @@ -903,8 +847,6 @@ subflow-attribute-mapper - - transition @@ -961,8 +903,6 @@ history - - value @@ -971,8 +911,6 @@ value - - var @@ -1019,8 +957,6 @@ all Spring beans can be resolved with EL - - view-state @@ -1085,8 +1021,6 @@ history - - * @@ -1095,8 +1029,6 @@ persistence-context - - * @@ -1113,8 +1045,6 @@ fragments - - * diff --git a/src/reference/flow-inheritance.xml b/src/reference/flow-inheritance.xml index 68020866..b5e016c8 100644 --- a/src/reference/flow-inheritance.xml +++ b/src/reference/flow-inheritance.xml @@ -1,10 +1,14 @@ - + Flow Inheritance - + Introduction Flow inheritance allows one flow to inherit the configuration of another flow. @@ -15,7 +19,7 @@ In order for a parent flow to be found, it must be added to the flow-registry just like any other flow. - + Is flow inheritance like Java inheritance? Flow inheritance is similar to Java inheritance in that elements defined in a parent are exposed via the child, however, there are key differences. @@ -30,9 +34,9 @@ Java inheritance is limited to a single class. - + Types of Flow Inheritance - + Flow level inheritance Flow level inheritance is defined by the parent attribute on the flow element. @@ -44,7 +48,7 @@ ]]> - + State level inheritance State level inheritance is similar to flow level inheritance, except only one state inherits from the parent, instead of the entire flow. @@ -52,7 +56,7 @@ Unlike flow inheritance, only a single parent is allowed. Additionally, the identifier of the flow state to inherit from must also be defined. - The identifiers for the flow and the state within that flow are separated by a #. + The identifiers for the flow and the state within that flow are separated by a #. The parent and child states must be of the same type. @@ -63,7 +67,7 @@ - + Abstract flows Often parent flows are not designed to be executed directly. @@ -74,7 +78,7 @@ ]]> - + Inheritance Algorithm When a child flow inherits from it's parent, essentially what happens is that the parent and child are merged together to create a new flow. @@ -93,12 +97,12 @@ Once merged, all relative paths in the parent flow will become relative to the child flow. - + Mergeable Elements If the elements are of the same type and their keyed attribute are identical, the content of the parent element will be merged with the child element. The merge algorithm will continue to merge each sub-element of the merging parent and child. - Otherwise the parent element is added as a new element to the child. + Otherwise the parent element is added as a new element to the child. In most cases, elements from a parent flow that are added will be added after elements in the child flow. @@ -162,7 +166,7 @@ - + Non-mergeable Elements Non-mergeable elements are: diff --git a/src/reference/flow-managed-persistence.xml b/src/reference/flow-managed-persistence.xml index 821bc299..04fb4046 100644 --- a/src/reference/flow-managed-persistence.xml +++ b/src/reference/flow-managed-persistence.xml @@ -1,10 +1,14 @@ - + Flow Managed Persistence - + Introduction Most applications access data in some way. @@ -19,7 +23,7 @@ This chapter will focus on the flow-managed persistence, exploring how and when to use this feature. - + FlowScoped PersistenceContext This pattern creates a PersistenceContext in flowScope on flow startup, @@ -41,12 +45,12 @@ http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> - + ]]> Then configure the correct FlowExecutionListener to apply this pattern to your flow. - If using Hibernate, register the HibernateFlowExecutionListener. If using JPA, register the JpaFlowExecutionListener. + If using Hibernate, register the HibernateFlowExecutionListener. If using JPA, register the JpaFlowExecutionListener. @@ -54,8 +58,8 @@ - - @@ -67,7 +71,7 @@ -]]> +]]> That is it. When your flow starts, the listener will handle allocating a new EntityManager in flowScope. @@ -76,13 +80,13 @@ Such data access operations should always execute non transactionally or in read-only transactions to maintain isolation of intermediate edits. - + Flow Managed Persistence And Sub-Flows A flow managed PersistenceContext is automatically extended (propagated) to subflows assuming the subflow also has the <perstistence-context/> - variable. When a subflow re-uses the PersistenceContext started by its parent it ignores - commit flags when an end state is reached thereby deferring the final decision (to commit or not) to + variable. When a subflow re-uses the PersistenceContext started by its parent it ignores + commit flags when an end state is reached thereby deferring the final decision (to commit or not) to its parent. diff --git a/src/reference/flow-security.xml b/src/reference/flow-security.xml index 4101d9ff..21c5c2ee 100644 --- a/src/reference/flow-security.xml +++ b/src/reference/flow-security.xml @@ -1,10 +1,14 @@ - + Securing Flows - + Introduction Security is an important concept for any application. @@ -14,7 +18,7 @@ This section will focus on securing flow execution. - + How do I secure a flow? Securing flow execution is a three step process: @@ -28,7 +32,7 @@ Each of these steps must be completed or else flow security rules will not be applied. - + The secured element The secured element designates that its containing element should apply the authorization check before fully entering. @@ -39,14 +43,14 @@ In each case the syntax for the secured element is identical. The secured element is located inside the element it is securing. For example, to secure a state the secured element occurs directly inside that state: - + ... ]]> - + Security attributes The attributes attribute is a comma separated list of Spring Security authorization attributes. @@ -61,7 +65,7 @@ This will need to be overridden if your application is not using authorization roles. - + Matching type There are two types of matching available: any and all. @@ -80,7 +84,7 @@ - + The SecurityFlowExecutionListener Defining security rules in the flow by themselves will not protect the flow execution. @@ -93,7 +97,7 @@ - ]]> @@ -101,12 +105,12 @@ This exception will later be caught by Spring Security and used to prompt the user to authenticate. It is important that this exception be allowed to travel up the execution stack uninhibited, otherwise the end user may not be prompted to authenticate. - + Custom Access Decision Managers If your application is using authorities that are not role based, you will need to configure a custom AccessDecisionManager. You can override the default decision manager by setting the accessDecisionManager property on the security listener. - Please consult the Spring Security reference documentation to learn more about decision managers. + Please consult the Spring Security reference documentation to learn more about decision managers. - + Configuring Spring Security Spring Security has robust configuration options available. - As every application and environment has its own security requirements, the Spring Security reference documentation is the best place to learn the available options. + As every application and environment has its own security requirements, the Spring Security reference documentation is the best place to learn the available options. Both the booking-faces and booking-mvc sample applications are configured to use Spring Security. Configuration is needed at both the Spring and web.xml levels. - + Spring configuration The Spring configuration defines http specifics (such as protected URLs and login/logout mechanics) and the authentication-provider. @@ -134,29 +138,29 @@ - + default-target-url="/spring/main" + authentication-failure-url="/spring/login?login_error=1" /> - - - - ]]> - + web.xml Configuration In the web.xml file, a filter is defined to intercept all requests. diff --git a/src/reference/index.xml b/src/reference/index.xml index d51791c3..f7403c79 100644 --- a/src/reference/index.xml +++ b/src/reference/index.xml @@ -1,9 +1,14 @@ - - + + + Spring Web Flow Reference Guide Spring Web Flow Spring Web Flow @@ -11,28 +16,40 @@ - Keith - Donald + + Keith + Donald + - Erwin - Vervaet + + Erwin + Vervaet + - Jeremy - Grelle + + Jeremy + Grelle + - Scott - Andrews + + Scott + Andrews + - Rossen - Stoyanchev + + Rossen + Stoyanchev + - Phillip - Webb + + Phillip + Webb + @@ -44,11 +61,11 @@ or electronically. - - + + - - + + Preface Many web applications require the same sequence of steps to execute in different contexts. @@ -65,7 +82,7 @@ This reference guide shows you how to use and extend Spring Web Flow. - + @@ -83,5 +100,5 @@ - + diff --git a/src/reference/overview.xml b/src/reference/overview.xml index 140241d4..c57ed12d 100644 --- a/src/reference/overview.xml +++ b/src/reference/overview.xml @@ -1,10 +1,14 @@ - + Introduction - + What this guide covers This guide covers all aspects of Spring Web Flow. @@ -12,7 +16,7 @@ It also covers extending the framework and the overall architectural model. - + What Web Flow requires to run Java 1.5 or higher @@ -21,34 +25,34 @@ Spring 3.1 or higher - + Where to get support Professional from-the-source support on Spring Web Flow is available from - SpringSource, the company behind Spring, and - Ervacon, operated by Web Flow project co-founder Erwin Vervaet + SpringSource, the company behind Spring, and + Ervacon, operated by Web Flow project co-founder Erwin Vervaet - + Where to follow development - You can help make Web Flow best serve the needs of the Spring community by interacting with developers - at the Spring Community Forums. + You can help make Web Flow best serve the needs of the Spring community by interacting with developers + at the Spring Community Forums. - Report bugs and influence the Web Flow project roadmap using the Spring Issue Tracker. + Report bugs and influence the Web Flow project roadmap using the Spring Issue Tracker. - Subscribe to the Spring Community Portal for the latest Spring news and announcements. + Subscribe to the Spring Community Portal for the latest Spring news and announcements. - Visit the Web Flow Project Home for more resources on the project. + Visit the Web Flow Project Home for more resources on the project. - + How to access Web Flow artifacts from Maven Central - Each jar in the Web Flow distribution is available in the Maven Central Repository. + Each jar in the Web Flow distribution is available in the Maven Central Repository. This allows you to easily integrate Web Flow into your application if you are already using Maven as the build system for your web development project. @@ -70,11 +74,11 @@ org.springframework.webflow spring-faces x.y.z.RELEASE - + ]]> - + How to access Web Flow artifacts with Ivy To access Spring Web Flow jars with Ivy, add the following repositories to your Ivy config: @@ -133,7 +137,7 @@ For milestones and snapshots you'll need to use the SpringSource repository. Add the following repository to your Maven pom.xml: - + springsource-repository @@ -142,20 +146,20 @@ ]]> - Then declare the following dependencies: + Then declare the following dependencies: org.springframework.webflow spring-binding x.y.z.BUILD-SNAPSHOT - + org.springframework.webflow spring-js x.y.z.BUILD-SNAPSHOT - + org.springframework.webflow diff --git a/src/reference/portlet.xml b/src/reference/portlet.xml index 1f58b42f..53b18b19 100644 --- a/src/reference/portlet.xml +++ b/src/reference/portlet.xml @@ -1,23 +1,27 @@ - + Portlet Integration - + Introduction This chapter shows how to use Web Flow in a Portlet environment. - Spring Web Flow requires Portlet API 2.0 to run with. + Spring Web Flow requires Portlet API 2.0 to run with. The booking-portlet-mvc sample application is a good reference for using Web Flow within a portlet. This application is a simplified travel site that allows users to search for and book hotel rooms. - + 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 sample applications, included with Web Flow, are both configured to use Apache Pluto. In general, the configuration requires adding a servlet mapping in the web.xml file to dispatch request to the portlet container. @@ -41,7 +45,7 @@ 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. + Setting the expiration-cache to 0 is recommended to force Web Flow to always render a fresh view. @@ -60,9 +64,9 @@ ]]> - + Configuring Spring - + Flow Handlers The only supported mechanism for bridging a portlet request to Web Flow is a FlowHandler. @@ -99,19 +103,19 @@ public class ViewFlowHandler extends AbstractFlowHandler { } ]]> - + Handler Mappings Spring Portlet MVC provides a rich set of methods to map portlet requests. - Complete documentation is available in the Spring Reference Documentation. + 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. + Other modes can be added and point to the same flow as view mode, or any other flow. @@ -123,21 +127,21 @@ public class ViewFlowHandler extends AbstractFlowHandler { ]]> - + Flow Handler Adapter A FlowHandlerAdapter converts the handler mappings to the flow handlers. The flow executor is required as a constructor argument. ]]> - + Portlet Views In order to facilitate view rendering, a ViewRendererServlet must be added to the web.xml file. @@ -155,9 +159,9 @@ public class ViewFlowHandler extends AbstractFlowHandler { ]]> - + Portlet Modes and Window States - + Window State The Portlet API defined three window states: normal, minimized and maximized. @@ -171,7 +175,7 @@ requestContext.getExternalContext().getRequestMap().get("portletWindowState"); externalContext.requestMap.portletWindowState ]]> - + Portlet Mode The Portlet API defined three portlet modes: view, edit and help. @@ -186,40 +190,40 @@ externalContext.requestMap.portletMode ]]> - + Using Portlets with JSF - + - Prior to version 2.1 of Spring Web Flow, support for JSF Portlets was considered - experimental and relied on a Portlet Bridge for JSF implementation. - Furthermore JSR-329 (the latest specification in this area), which targets + Prior to version 2.1 of Spring Web Flow, support for JSF Portlets was considered + experimental and relied on a Portlet Bridge for JSF implementation. + Furthermore JSR-329 (the latest specification in this area), which targets Portlet API 2.0 and JSF 1.2 environments at the time of writing is not yet final causing portlet bridge implementations to also remain incomplete. A closer comparison of Spring Web Flow and a Portlet Bridge for JSF shows - the two have significant overlap. They both drive the + the two have significant overlap. They both drive the JSF lifecycle and they both shield JSF from knowledge about Portlet action - and render requests. + and render requests. - Considering all of the above, starting with version 2.2, Spring Web Flow + Considering all of the above, starting with version 2.2, Spring Web Flow provides support for JSF Portlets using its own internal Portlet integration rather than a Portlet Bridge for JSF. We believe this will provide value for Web Flow users by reducing the number of dependencies in what is already a fairly complex combination of technologies with specifications lagging behind. - What this practically means is the configuration required for JSF Portlets is + What this practically means is the configuration required for JSF Portlets is very similar to what is alread documented in the rest of this chapter - with the exception of , which is not necessary + with the exception of , which is not necessary with JSF. Review the swf-booking-portlet-faces sample in the Web Flow distribution for a working JSF Portlets example with complete configuration details. The main things to ensure are that the <faces:resources> elements is - included as part of your Spring configuration and that your + included as part of your Spring configuration and that your faces-config.xml configuration includes a PortletViewHandler: @@ -232,27 +236,27 @@ externalContext.requestMap.portletMode org.springframework.faces.webflow.context.portlet.PortletViewHandler - + ]]> The JSF Portlet support provided with Spring Web Flow requires JSF v2.0 or above. If - you are upgrading from a previous release you should ensure that your faces-config.xml + you are upgrading from a previous release you should ensure that your faces-config.xml references org.springframework.faces.webflow.context.portlet.PortletViewHandler instead of org.springframework.faces.webflow.application.portlet.PortletFaceletViewHandler. You should also ensure that you have added <faces:resources> to you Spring configuration. Although JSF v2.0 is a minimum requirement, this has been primarily driven to provide better support in - a Servlet environment. Many of the more advanced JSF 2.0 features (for example 'Partial State Saving') + a Servlet environment. Many of the more advanced JSF 2.0 features (for example 'Partial State Saving') are not supported by Spring Web Flow in a Portlet environment. - + Issues in a Portlet Environment - + Redirects The Portlet API only allows redirects to be requested from an action request. @@ -267,7 +271,7 @@ externalContext.requestMap.portletMode This callback provides the ActionResponse object which supports redirects. - + Switching Portlet Modes The portlet container passes the execution key from the previous flow when switching to a new mode. diff --git a/src/reference/spring-faces.xml b/src/reference/spring-faces.xml index 388c25ae..a6bd26c5 100644 --- a/src/reference/spring-faces.xml +++ b/src/reference/spring-faces.xml @@ -1,715 +1,719 @@ - - JSF Integration + + JSF Integration - - Introduction + + Introduction - Spring Web Flow provides a JSF integration that simplifies using JSF - with Spring. It lets you use the JSF UI Component Model with Spring MVC - and Spring Web Flow controllers. Along with the JSF integration Spring Web - Flow provides a Spring Security tag library for use in JSF environments - (see for more details). - + Spring Web Flow provides a JSF integration that simplifies using JSF + with Spring. It lets you use the JSF UI Component Model with Spring MVC + and Spring Web Flow controllers. Along with the JSF integration Spring Web + Flow provides a Spring Security tag library for use in JSF environments + (see for more details). + - Starting with Spring Web Flow version 2.4, JSF integration requires - JSF v2.0 or above. Both Sun Mojarra and Apache MyFaces runtime environments - are supported. + Starting with Spring Web Flow version 2.4, JSF integration requires + JSF v2.0 or above. Both Sun Mojarra and Apache MyFaces runtime environments + are supported. - Spring Web Flow also supports using JSF in a portlet environment. - Spring Web Flow's portlet integration supports Portlets API 2.0. - See for more on Spring Web Flow's portlet - integration. - + Spring Web Flow also supports using JSF in a portlet environment. + Spring Web Flow's portlet integration supports Portlets API 2.0. + See for more on Spring Web Flow's portlet + integration. + - - JSF Integration For Spring Developers + + JSF Integration For Spring Developers - Spring Web Flow complements the strengths of JSF, its component - model, and provides more sophisticated state management and navigation. In - addition you have the ability to use Spring MVC @Controller or flow - definitions as controllers in the web layer. + Spring Web Flow complements the strengths of JSF, its component + model, and provides more sophisticated state management and navigation. In + addition you have the ability to use Spring MVC @Controller or flow + definitions as controllers in the web layer. - JSF applications using Spring Web Flow applications gain benefits in - the following areas: - - Managed bean facility - + JSF applications using Spring Web Flow applications gain benefits in + the following areas: + + Managed bean facility + - - Scope management - + + Scope management + - - Event handling - + + Event handling + - - Navigation - + + Navigation + - - Modularization and packaging of views - + + Modularization and packaging of views + - - Cleaner URLs - + + Cleaner URLs + - - Model-level validation - - Using these features significantly reduce the amount of - configuration required in faces-config.xml. They provide a cleaner - separation between the view and controller layers along with better - modularization of application functionals. These features are detailed in - the sections to follow. The majority of these features build on the flow - definition language of Spring Web Flow. Therefore it is assumed that you - have an understanding of the foundations presented in . - + + Model-level validation + + Using these features significantly reduce the amount of + configuration required in faces-config.xml. They provide a cleaner + separation between the view and controller layers along with better + modularization of application functionals. These features are detailed in + the sections to follow. The majority of these features build on the flow + definition language of Spring Web Flow. Therefore it is assumed that you + have an understanding of the foundations presented in . + - - Upgrading from Spring Web Flow 2.3 + + Upgrading from Spring Web Flow 2.3 - If you are upgrading from Spring Web Flow 2.3 or earlier you may need to - update several aspects of your project. JSF 2.0 is now a minimum requirement - and as result some components from previous releases are no longer included. + If you are upgrading from Spring Web Flow 2.3 or earlier you may need to + update several aspects of your project. JSF 2.0 is now a minimum requirement + and as result some components from previous releases are no longer included. - - Spring Faces Components - Previous releases of Spring Web Flow shipped with a component library - which provided Ajax and client-side validation capabilities for JSF 1.2 - environments. Applications using these components will need to switch to a - 3rd party JSF component library such as PrimeFaces or RichFaces. - Components that have been removed include <sf:clientTextValidator>, - <sf:clientNumberValidator>, <sf:clientDateValidator>, - <sf:validateAllOnClick>, <sf:resource> and - <sf:resourceGroup>. - The swf-booking-faces sample in the Spring Web Flow distribution - shows an example built with PrimeFaces components. - + + Spring Faces Components + Previous releases of Spring Web Flow shipped with a component library + which provided Ajax and client-side validation capabilities for JSF 1.2 + environments. Applications using these components will need to switch to a + 3rd party JSF component library such as PrimeFaces or RichFaces. + Components that have been removed include <sf:clientTextValidator>, + <sf:clientNumberValidator>, <sf:clientDateValidator>, + <sf:validateAllOnClick>, <sf:resource> and + <sf:resourceGroup>. + The swf-booking-faces sample in the Spring Web Flow distribution + shows an example built with PrimeFaces components. + - - Configuring faces-config.xml - If your application defines a faces-config.xml file you should - ensure that the correct schema version is specified. In addition you should remove - any FaceletViewHandler references as Facelets are now the default rendering - technology for JSF 2.0 + + Configuring faces-config.xml + If your application defines a faces-config.xml file you should + ensure that the correct schema version is specified. In addition you should remove + any FaceletViewHandler references as Facelets are now the default rendering + technology for JSF 2.0 - + <?xml version='1.0' encoding='UTF-8'?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" - version="2.0"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" + version="2.0"> </faces-config> - - + + - - Third-party Libraries - Previous releases of Spring Web Flow would often require additional configuration in order - for 3rd party component libraries to work correctly. JSF 2.0 introduced standard resource - loading mechanisms that removes the need for such custom configuration. As long as you - have a <faces:resources> element in your Spring configuration, libraries - such as RichFaces or Apache Trinidad you should work. - + + Third-party Libraries + Previous releases of Spring Web Flow would often require additional configuration in order + for 3rd party component libraries to work correctly. JSF 2.0 introduced standard resource + loading mechanisms that removes the need for such custom configuration. As long as you + have a <faces:resources> element in your Spring configuration, libraries + such as RichFaces or Apache Trinidad you should work. + - - Spring Security Facelets Tag Library - If you have a previously configured /WEB-INF/springsecurity.taglib.xml file - you may need to update the contents. See for - details. - - + + Spring Security Facelets Tag Library + If you have a previously configured /WEB-INF/springsecurity.taglib.xml file + you may need to update the contents. See for + details. + + - - Configuring web.xml + + Configuring web.xml - The first step is to route requests to the - DispatcherServlet in the web.xml file. In this - example, we map all URLs that begin with /spring/ to the - servlet. The servlet needs to be configured. An init-param is - used in the servlet to pass the contextConfigLocation. This - is the location of the Spring configuration for your web - application. + The first step is to route requests to the + DispatcherServlet in the web.xml file. In this + example, we map all URLs that begin with /spring/ to the + servlet. The servlet needs to be configured. An init-param is + used in the servlet to pass the contextConfigLocation. This + is the location of the Spring configuration for your web + application. - + <servlet> - <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> - <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> - <init-param> - <param-name>contextConfigLocation</param-name> - <param-value>/WEB-INF/web-application-config.xml</param-value> - </init-param> - <load-on-startup>1</load-on-startup> + <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> + <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> + <init-param> + <param-name>contextConfigLocation</param-name> + <param-value>/WEB-INF/web-application-config.xml</param-value> + </init-param> + <load-on-startup>1</load-on-startup> </servlet> - + <servlet-mapping> - <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> - <url-pattern>/spring/*</url-pattern> + <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> + <url-pattern>/spring/*</url-pattern> </servlet-mapping> - + - In order for JSF to bootstrap correctly, the - FacesServlet must be configured in web.xml as it - normally would even though you generally will not need to route requests - through it at all when using JSF with Spring Web Flow. + In order for JSF to bootstrap correctly, the + FacesServlet must be configured in web.xml as it + normally would even though you generally will not need to route requests + through it at all when using JSF with Spring Web Flow. - + <!-- Just here so the JSF implementation can initialize, *not* used at runtime --> <servlet> - <servlet-name>Faces Servlet</servlet-name> - <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> - <load-on-startup>1</load-on-startup> + <servlet-name>Faces Servlet</servlet-name> + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> + <load-on-startup>1</load-on-startup> </servlet> - + <!-- Just here so the JSF implementation can initialize --> <servlet-mapping> - <servlet-name>Faces Servlet</servlet-name> - <url-pattern>*.faces</url-pattern> + <servlet-name>Faces Servlet</servlet-name> + <url-pattern>*.faces</url-pattern> </servlet-mapping> - + - The use of Facelets instead of JSP typically requires this in - web.xml: + The use of Facelets instead of JSP typically requires this in + web.xml: - + !-- Use JSF view templates saved as *.xhtml, for use with Facelets --> <context-param> - <param-name>javax.faces.DEFAULT_SUFFIX</param-name> - <param-value>.xhtml</param-value> + <param-name>javax.faces.DEFAULT_SUFFIX</param-name> + <param-value>.xhtml</param-value> </context-param> - + - + - - Configuring Web Flow for use with JSF + + Configuring Web Flow for use with JSF - This section explains how to configure Web Flow with JSF. The - following is sample configuration for Web Flow and JSF: + This section explains how to configure Web Flow with JSF. The + following is sample configuration for Web Flow and JSF: - + <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:webflow="http://www.springframework.org/schema/webflow-config" - xmlns:faces="http://www.springframework.org/schema/faces" - si:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/webflow-config - http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd - http://www.springframework.org/schema/faces - http://www.springframework.org/schema/faces/spring-faces-2.2.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:webflow="http://www.springframework.org/schema/webflow-config" + xmlns:faces="http://www.springframework.org/schema/faces" + si:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/webflow-config + http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd + http://www.springframework.org/schema/faces + http://www.springframework.org/schema/faces/spring-faces-2.2.xsd"> - <!-- Executes flows: the central entry point into the Spring Web Flow system --> - <webflow:flow-executor id="flowExecutor"> - <webflow:flow-execution-listeners> - <webflow:listener ref="facesContextListener"/> - </webflow:flow-execution-listeners> - </webflow:flow-executor> - - <!-- The registry of executable flow definitions --> - <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF"> - <webflow:flow-location-pattern value="**/*-flow.xml" /> - </webflow:flow-registry> + <!-- Executes flows: the central entry point into the Spring Web Flow system --> + <webflow:flow-executor id="flowExecutor"> + <webflow:flow-execution-listeners> + <webflow:listener ref="facesContextListener"/> + </webflow:flow-execution-listeners> + </webflow:flow-executor> - <!-- Configures the Spring Web Flow JSF integration --> - <faces:flow-builder-services id="flowBuilderServices" /> + <!-- The registry of executable flow definitions --> + <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF"> + <webflow:flow-location-pattern value="**/*-flow.xml" /> + </webflow:flow-registry> - <!-- A listener maintain one FacesContext instance per Web Flow request. --> - <bean id="facesContextListener" - class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" /> + <!-- Configures the Spring Web Flow JSF integration --> + <faces:flow-builder-services id="flowBuilderServices" /> + + <!-- A listener maintain one FacesContext instance per Web Flow request. --> + <bean id="facesContextListener" + class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" /> </beans> - + - The main points are the installation of a - FlowFacesContextLifecycleListener that manages a single - FacesContext for the duration of Web Flow request and the use of the - flow-builder-services element from the faces - custom namespace to configure rendering for a JSF environment. + The main points are the installation of a + FlowFacesContextLifecycleListener that manages a single + FacesContext for the duration of Web Flow request and the use of the + flow-builder-services element from the faces + custom namespace to configure rendering for a JSF environment. - In a JSF environment you'll also need this Spring MVC related - configuration: + In a JSF environment you'll also need this Spring MVC related + configuration: - + <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:faces="http://www.springframework.org/schema/faces" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/faces - http://www.springframework.org/schema/faces/spring-faces-2.2.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:faces="http://www.springframework.org/schema/faces" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/faces + http://www.springframework.org/schema/faces/spring-faces-2.2.xsd"> - <faces:resources /> - - <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter"> - <property name="flowExecutor" ref="flowExecutor" /> - </bean> + <faces:resources /> + + <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter"> + <property name="flowExecutor" ref="flowExecutor" /> + </bean> </beans> - + - The resources custom namespace element delegates JSF - resource requests to the JSF resource API. The - JsfFlowHandlerAdapter is a replacement for the - FlowHandlerAdapter normally used with Web Flow. This adapter - initializes itself with a JsfAjaxHandler instead of the - SpringJavaSciprtAjaxHandler. - + The resources custom namespace element delegates JSF + resource requests to the JSF resource API. The + JsfFlowHandlerAdapter is a replacement for the + FlowHandlerAdapter normally used with Web Flow. This adapter + initializes itself with a JsfAjaxHandler instead of the + SpringJavaSciprtAjaxHandler. + - - Replacing the JSF Managed Bean Facility + + Replacing the JSF Managed Bean Facility - When using JSF with Spring Web Flow you can completely replace the - JSF managed bean facility with a combination of Web Flow managed variables - and Spring managed beans. It gives you a good deal more control over the - lifecycle of your managed objects with well-defined hooks for - initialization and execution of your domain model. Additionally, since you - are presumably already using Spring for your business layer, it reduces - the conceptual overhead of having to maintain two different managed bean - models. + When using JSF with Spring Web Flow you can completely replace the + JSF managed bean facility with a combination of Web Flow managed variables + and Spring managed beans. It gives you a good deal more control over the + lifecycle of your managed objects with well-defined hooks for + initialization and execution of your domain model. Additionally, since you + are presumably already using Spring for your business layer, it reduces + the conceptual overhead of having to maintain two different managed bean + models. - In doing pure JSF development, you will quickly find that request - scope is not long-lived enough for storing conversational model objects - that drive complex event-driven views. In JSF the usual option is to begin - putting things into session scope, with the extra - burden of needing to clean the objects up before progressing to another - view or functional area of the application. What is really needed is a - managed scope that is somewhere between request and session scope. JSF - provides flash and view scopes that can be accessed programmatically via - UIViewRoot.getViewMap(). Spring Web Flow provides access to flash, view, - flow, and conversation scopes. These scopes are seamlessly integrated - through JSF variable resolvers and work the same in all JSF - applications. + In doing pure JSF development, you will quickly find that request + scope is not long-lived enough for storing conversational model objects + that drive complex event-driven views. In JSF the usual option is to begin + putting things into session scope, with the extra + burden of needing to clean the objects up before progressing to another + view or functional area of the application. What is really needed is a + managed scope that is somewhere between request and session scope. JSF + provides flash and view scopes that can be accessed programmatically via + UIViewRoot.getViewMap(). Spring Web Flow provides access to flash, view, + flow, and conversation scopes. These scopes are seamlessly integrated + through JSF variable resolvers and work the same in all JSF + applications. - - Using Flow Variables + + Using Flow Variables - The easiest and most natural way to declare and manage the model - is through the use of flow - variables. You can declare these variables at the beginning of - the flow: + The easiest and most natural way to declare and manage the model + is through the use of flow + variables. You can declare these variables at the beginning of + the flow: - + <var name="searchCriteria" class="com.mycompany.myapp.hotels.search.SearchCriteria"/> - + - and then reference this variable in one of the flow's JSF view - templates through EL: + and then reference this variable in one of the flow's JSF view + templates through EL: - + <h:inputText id="searchString" value="#{searchCriteria.searchString}"/> - + - Note that you do not need to prefix the variable with its scope - when referencing it from the template (though you can do so if you need - to be more specific). As with standard JSF beans, all available scopes - will be searched for a matching variable, so you could change the scope - of the variable in your flow definition without having to modify the EL - expressions that reference it. + Note that you do not need to prefix the variable with its scope + when referencing it from the template (though you can do so if you need + to be more specific). As with standard JSF beans, all available scopes + will be searched for a matching variable, so you could change the scope + of the variable in your flow definition without having to modify the EL + expressions that reference it. - You can also define view instance variables that are scoped to the - current view and get cleaned up automatically upon transitioning to - another view. This is quite useful with JSF as views are often - constructed to handle multiple in-page events across many requests - before transitioning to another view. + You can also define view instance variables that are scoped to the + current view and get cleaned up automatically upon transitioning to + another view. This is quite useful with JSF as views are often + constructed to handle multiple in-page events across many requests + before transitioning to another view. - To define a view instance variable, you can use the - var element inside a view-state - definition: + To define a view instance variable, you can use the + var element inside a view-state + definition: - -<view-state id="enterSearchCriteria"> - <var name="searchCriteria" class="com.mycompany.myapp.hotels.search.SearchCriteria"/> + +<view-state id="enterSearchCriteria"> + <var name="searchCriteria" class="com.mycompany.myapp.hotels.search.SearchCriteria"/> </view-state> - - + + - - Using Scoped Spring Beans + + Using Scoped Spring Beans - Though defining autowired flow instance variables provides nice - modularization and readability, occasions may arise where you want to - utilize the other capabilities of the Spring container such as AOP. In - these cases, you can define a bean in your Spring ApplicationContext and - give it a specific web flow scope: + Though defining autowired flow instance variables provides nice + modularization and readability, occasions may arise where you want to + utilize the other capabilities of the Spring container such as AOP. In + these cases, you can define a bean in your Spring ApplicationContext and + give it a specific web flow scope: - + <bean id="searchCriteria" class="com.mycompany.myapp.hotels.search.SearchCriteria" scope="flow"/> - + - The major difference with this approach is that the bean will not - be fully initialized until it is first accessed via an EL expression. - This sort of lazy instantiation via EL is quite similar to how JSF - managed beans are typically allocated. - + The major difference with this approach is that the bean will not + be fully initialized until it is first accessed via an EL expression. + This sort of lazy instantiation via EL is quite similar to how JSF + managed beans are typically allocated. + - - Manipulating The Model + + Manipulating The Model - The need to initialize the model before view rendering (such as by - loading persistent entities from a database) is quite common, but JSF by - itself does not provide any convenient hooks for such initialization. - The flow definition language provides a natural facility for this - through its Actions . Spring Web - Flow provides some extra conveniences for converting the outcome of an - action into a JSF-specific data structure. For example: + The need to initialize the model before view rendering (such as by + loading persistent entities from a database) is quite common, but JSF by + itself does not provide any convenient hooks for such initialization. + The flow definition language provides a natural facility for this + through its Actions . Spring Web + Flow provides some extra conveniences for converting the outcome of an + action into a JSF-specific data structure. For example: - + <on-render> - <evaluate expression="bookingService.findBookings(currentUser.name)" - result="viewScope.bookings" result-type="dataModel" /> + <evaluate expression="bookingService.findBookings(currentUser.name)" + result="viewScope.bookings" result-type="dataModel" /> </on-render> - + - This will take the result of the - bookingService.findBookings method an wrap it in a custom - JSF DataModel so that the list can be used in a standard JSF DataTable - component: + This will take the result of the + bookingService.findBookings method an wrap it in a custom + JSF DataModel so that the list can be used in a standard JSF DataTable + component: - -<h:dataTable id="bookings" styleClass="summary" value="#{bookings}" var="booking" - rendered="#{bookings.rowCount > 0}"> - <h:column> - <f:facet name="header">Name</f:facet> - #{booking.hotel.name} - </h:column> - <h:column> - <f:facet name="header">Confirmation number</f:facet> - #{booking.id} - </h:column> - <h:column> - <f:facet name="header">Action</f:facet> - <h:commandLink id="cancel" value="Cancel" action="cancelBooking" /> - </h:column> + +<h:dataTable id="bookings" styleClass="summary" value="#{bookings}" var="booking" + rendered="#{bookings.rowCount > 0}"> + <h:column> + <f:facet name="header">Name</f:facet> + #{booking.hotel.name} + </h:column> + <h:column> + <f:facet name="header">Confirmation number</f:facet> + #{booking.id} + </h:column> + <h:column> + <f:facet name="header">Action</f:facet> + <h:commandLink id="cancel" value="Cancel" action="cancelBooking" /> + </h:column> </h:dataTable> - - + + - - Data Model Implementations + + Data Model Implementations - In the example above result-type="dataModel" results in the - wrapping of List<Booking> with custom - DataModel type. The custom - DataModel provides extra conveniences such as - being serializable for storage beyond request scope as well as access to - the currently selected row in EL expressions. For example, on postback - from a view where the action event was fired by a component within a - DataTable, you can take action on the selected row's model - instance: + In the example above result-type="dataModel" results in the + wrapping of List<Booking> with custom + DataModel type. The custom + DataModel provides extra conveniences such as + being serializable for storage beyond request scope as well as access to + the currently selected row in EL expressions. For example, on postback + from a view where the action event was fired by a component within a + DataTable, you can take action on the selected row's model + instance: - + <transition on="cancelBooking"> - <evaluate expression="bookingService.cancelBooking(bookings.selectedRow)" /> + <evaluate expression="bookingService.cancelBooking(bookings.selectedRow)" /> </transition> - + - Spring Web Flow provides two custom DataModel types: - OneSelectionTrackingListDataModel and - ManySelectionTrackingListDataModel. As the names - indicate they keep track of one or multiple selected rows. This is done - with the help of a - SelectionTrackingActionListener listener, which - responds to JSF action events and invokes the appopriate methods on the - SelectinAware data models to record the currently - clicked row. + Spring Web Flow provides two custom DataModel types: + OneSelectionTrackingListDataModel and + ManySelectionTrackingListDataModel. As the names + indicate they keep track of one or multiple selected rows. This is done + with the help of a + SelectionTrackingActionListener listener, which + responds to JSF action events and invokes the appopriate methods on the + SelectinAware data models to record the currently + clicked row. - To understand how this is configured, keep in mind the - FacesConversionService registers a - DataModelConverter against the alias "dataModel" - on startup. When result-type="dataModel" is used in a flow definition it - causes the DataModelConverter to be used. The - converter then wraps the given List with an instance of - OneSelectionTrackingListDataModel. To use the - ManySelectionTrackingListDataModel you will need - to register your own custom converter. - - + To understand how this is configured, keep in mind the + FacesConversionService registers a + DataModelConverter against the alias "dataModel" + on startup. When result-type="dataModel" is used in a flow definition it + causes the DataModelConverter to be used. The + converter then wraps the given List with an instance of + OneSelectionTrackingListDataModel. To use the + ManySelectionTrackingListDataModel you will need + to register your own custom converter. + + - - Handling JSF Events With Spring Web Flow + + Handling JSF Events With Spring Web Flow - Spring Web Flow allows you to handle JSF action events in a - decoupled way, requiring no direct dependencies in your Java code on JSF - API's. In fact, these events can often be handled completely in the flow - definiton language without requiring any custom Java action code at all. - This allows for a more agile development process since the artifacts being - manipulated in wiring up events (JSF view templates and SWF flow - definitions) are instantly refreshable without requiring a build and - re-deploy of the whole application. + Spring Web Flow allows you to handle JSF action events in a + decoupled way, requiring no direct dependencies in your Java code on JSF + API's. In fact, these events can often be handled completely in the flow + definiton language without requiring any custom Java action code at all. + This allows for a more agile development process since the artifacts being + manipulated in wiring up events (JSF view templates and SWF flow + definitions) are instantly refreshable without requiring a build and + re-deploy of the whole application. - - Handling JSF In-page Action Events + + Handling JSF In-page Action Events - A simple but common case in JSF is the need to signal an event - that causes manipulation of the model in some way and then redisplays - the same view to reflect the changed state of the model. The flow - definition language has special support for this in the - transition element. + A simple but common case in JSF is the need to signal an event + that causes manipulation of the model in some way and then redisplays + the same view to reflect the changed state of the model. The flow + definition language has special support for this in the + transition element. - A good example of this is a table of paged list results. Suppose - you want to be able to load and display only a portion of a large result - list, and allow the user to page through the results. The initial - view-state definition to load and display the list would - be: + A good example of this is a table of paged list results. Suppose + you want to be able to load and display only a portion of a large result + list, and allow the user to page through the results. The initial + view-state definition to load and display the list would + be: - + <view-state id="reviewHotels"> - <on-render> - <evaluate expression="bookingService.findHotels(searchCriteria)" - result="viewScope.hotels" result-type="dataModel" /> - </on-render> + <on-render> + <evaluate expression="bookingService.findHotels(searchCriteria)" + result="viewScope.hotels" result-type="dataModel" /> + </on-render> </view-state> - + - You construct a JSF DataTable that displays the current - hotels list, and then place a "More Results" link below the - table: + You construct a JSF DataTable that displays the current + hotels list, and then place a "More Results" link below the + table: - + <h:commandLink id="nextPageLink" value="More Results" action="next"/> - + - This commandLink signals a "next" event from its action attribute. - You can then handle the event by adding to the view-state - definition: + This commandLink signals a "next" event from its action attribute. + You can then handle the event by adding to the view-state + definition: - + <view-state id="reviewHotels"> - <on-render> - <evaluate expression="bookingService.findHotels(searchCriteria)" - result="viewScope.hotels" result-type="dataModel" /> - </on-render> - <transition on="next"> - <evaluate expression="searchCriteria.nextPage()" /> - </transition> + <on-render> + <evaluate expression="bookingService.findHotels(searchCriteria)" + result="viewScope.hotels" result-type="dataModel" /> + </on-render> + <transition on="next"> + <evaluate expression="searchCriteria.nextPage()" /> + </transition> </view-state> - + - Here you handle the "next" event by incrementing the page count on - the searchCriteria instance. The on-render action is then - called again with the updated criteria, which causes the next page of - results to be loaded into the DataModel. The same view is re-rendered - since there was no to attribute on the - transition element, and the changes in the model are - reflected in the view. - + Here you handle the "next" event by incrementing the page count on + the searchCriteria instance. The on-render action is then + called again with the updated criteria, which causes the next page of + results to be loaded into the DataModel. The same view is re-rendered + since there was no to attribute on the + transition element, and the changes in the model are + reflected in the view. + - - Handling JSF Action Events + + Handling JSF Action Events - The next logical level beyond in-page events are events that - require navigation to another view, with some manipulation of the model - along the way. Achieving this with pure JSF would require adding a - navigation rule to faces-config.xml and likely some intermediary Java - code in a JSF managed bean (both tasks requiring a re-deploy). With the - flow defintion language, you can handle such a case concisely in one - place in a quite similar way to how in-page events are handled. + The next logical level beyond in-page events are events that + require navigation to another view, with some manipulation of the model + along the way. Achieving this with pure JSF would require adding a + navigation rule to faces-config.xml and likely some intermediary Java + code in a JSF managed bean (both tasks requiring a re-deploy). With the + flow defintion language, you can handle such a case concisely in one + place in a quite similar way to how in-page events are handled. - Continuing on with our use case of manipulating a paged list of - results, suppose we want each row in the displayed DataTable to contain - a link to a detail page for that row instance. You can add a column to - the table containing the following commandLink - component: + Continuing on with our use case of manipulating a paged list of + results, suppose we want each row in the displayed DataTable to contain + a link to a detail page for that row instance. You can add a column to + the table containing the following commandLink + component: - + <h:commandLink id="viewHotelLink" value="View Hotel" action="select"/> - + - This raises the "select" event which you can then handle by adding - another transition element to the existing - view-state : + This raises the "select" event which you can then handle by adding + another transition element to the existing + view-state : - + <view-state id="reviewHotels"> - <on-render> - <evaluate expression="bookingService.findHotels(searchCriteria)" - result="viewScope.hotels" result-type="dataModel" /> - </on-render> - <transition on="next"> - <evaluate expression="searchCriteria.nextPage()" /> - </transition> - <transition on="select" to="reviewHotel"> - <set name="flowScope.hotel" value="hotels.selectedRow" /> - </transition> + <on-render> + <evaluate expression="bookingService.findHotels(searchCriteria)" + result="viewScope.hotels" result-type="dataModel" /> + </on-render> + <transition on="next"> + <evaluate expression="searchCriteria.nextPage()" /> + </transition> + <transition on="select" to="reviewHotel"> + <set name="flowScope.hotel" value="hotels.selectedRow" /> + </transition> </view-state> - + - Here the "select" event is handled by pushing the currently - selected hotel instance from the DataTable into flow scope, so that it - may be referenced by the "reviewHotel" view-state . - + Here the "select" event is handled by pushing the currently + selected hotel instance from the DataTable into flow scope, so that it + may be referenced by the "reviewHotel" view-state . + - - Performing Model Validation + + Performing Model Validation - JSF provides useful facilities for validating input at field-level - before changes are applied to the model, but when you need to then - perform more complex validation at the model-level after the updates - have been applied, you are generally left with having to add more custom - code to your JSF action methods in the managed bean. Validation of this - sort is something that is generally a responsibility of the domain model - itself, but it is difficult to get any error messages propagated back to - the view without introducing an undesirable dependency on the JSF API in - your domain layer. + JSF provides useful facilities for validating input at field-level + before changes are applied to the model, but when you need to then + perform more complex validation at the model-level after the updates + have been applied, you are generally left with having to add more custom + code to your JSF action methods in the managed bean. Validation of this + sort is something that is generally a responsibility of the domain model + itself, but it is difficult to get any error messages propagated back to + the view without introducing an undesirable dependency on the JSF API in + your domain layer. - With Web Flow, you can utilize the generic and low-level - MessageContext in your business code and any messages added - there will then be available to the FacesContext at render - time. + With Web Flow, you can utilize the generic and low-level + MessageContext in your business code and any messages added + there will then be available to the FacesContext at render + time. - For example, suppose you have a view where the user enters the - necessary details to complete a hotel booking, and you need to ensure - the Check In and Check Out dates adhere to a given set of business - rules. You can invoke such model-level validation from a - transition element: + For example, suppose you have a view where the user enters the + necessary details to complete a hotel booking, and you need to ensure + the Check In and Check Out dates adhere to a given set of business + rules. You can invoke such model-level validation from a + transition element: - + <view-state id="enterBookingDetails"> - <transition on="proceed" to="reviewBooking"> - <evaluate expression="booking.validateEnterBookingDetails(messageContext)" /> - </transition> + <transition on="proceed" to="reviewBooking"> + <evaluate expression="booking.validateEnterBookingDetails(messageContext)" /> + </transition> </view-state> - + - Here the "proceed" event is handled by invoking a model-level - validation method on the booking instance, passing the generic - MessageContext instance so that messages may be recorded. - The messages can then be displayed along with any other JSF messages - with the h:messages component, + Here the "proceed" event is handled by invoking a model-level + validation method on the booking instance, passing the generic + MessageContext instance so that messages may be recorded. + The messages can then be displayed along with any other JSF messages + with the h:messages component, - - + + - - Handling Ajax Events In JSF + + Handling Ajax Events In JSF - JSF provides built-in support for sending Ajax requests and - performing partial processing and rendering on the server-side. You can - specify a list of id's for partial rendering through the <f:ajax> - facelets tag. + JSF provides built-in support for sending Ajax requests and + performing partial processing and rendering on the server-side. You can + specify a list of id's for partial rendering through the <f:ajax> + facelets tag. - In Spring Web Flow you also have the option to specify the ids to - use for partial rendering on the server side with the render - action: + In Spring Web Flow you also have the option to specify the ids to + use for partial rendering on the server side with the render + action: - + <view-state id="reviewHotels"> - <on-render> - <evaluate expression="bookingService.findHotels(searchCriteria)" - result="viewScope.hotels" result-type="dataModel" /> - </on-render> - <transition on="next"> - <evaluate expression="searchCriteria.nextPage()" /> - <render fragments="hotels:searchResultsFragment" /> - </transition> + <on-render> + <evaluate expression="bookingService.findHotels(searchCriteria)" + result="viewScope.hotels" result-type="dataModel" /> + </on-render> + <transition on="next"> + <evaluate expression="searchCriteria.nextPage()" /> + <render fragments="hotels:searchResultsFragment" /> + </transition> </view-state> - - - + + + - - Embedding a Flow On a Page + + Embedding a Flow On a Page - By default when a flow enters a view state, it executes a - client-side redirect before rendering the view. This approach is known as - POST-REDIRECT-GET. It has the advantage of separating the form processing - for one view from the rendering of the next view. As a result the browser - Back and Refresh buttons work seamlessly without causing any browser - warnings. + By default when a flow enters a view state, it executes a + client-side redirect before rendering the view. This approach is known as + POST-REDIRECT-GET. It has the advantage of separating the form processing + for one view from the rendering of the next view. As a result the browser + Back and Refresh buttons work seamlessly without causing any browser + warnings. - Normally the client-side redirect is transparent from a user's - perspective. However, there are situations where POST-REDIRECT-GET may not - bring the same benefits. For example sometimes it may be useful to embed - a flow on a page and drive it via Ajax requests refreshing only the area - of the page where the flow is rendered. Not only is it unnecessary to use - client-side redirects in this case, it is also not the desired behavior - with regards to keeping the surrounding content of the page intact. + Normally the client-side redirect is transparent from a user's + perspective. However, there are situations where POST-REDIRECT-GET may not + bring the same benefits. For example sometimes it may be useful to embed + a flow on a page and drive it via Ajax requests refreshing only the area + of the page where the flow is rendered. Not only is it unnecessary to use + client-side redirects in this case, it is also not the desired behavior + with regards to keeping the surrounding content of the page intact. - To indicate a flow should execute in "page embedded" mode all - you need to do is pass an extra flow input attribute called "mode" - with a value of "embedded". Below is an example of a top-level - container flow invoking a sub-flow in an embedded mode: + To indicate a flow should execute in "page embedded" mode all + you need to do is pass an extra flow input attribute called "mode" + with a value of "embedded". Below is an example of a top-level + container flow invoking a sub-flow in an embedded mode: - + <subflow-state id="bookHotel" subflow="booking"> - <input name="mode" value="'embedded'"/> + <input name="mode" value="'embedded'"/> </subflow-state> - - - When launched in "page embedded" mode the sub-flow will not issue - flow execution redirects during Ajax requests. + - If you'd like to see examples of an embedded flow please refer to - the webflow-primefaces-showcase project. You can check out - the source code locally, build it as you would a Maven project, and import - it into Eclipse: + When launched in "page embedded" mode the sub-flow will not issue + flow execution redirects during Ajax requests. - cd some-directory + If you'd like to see examples of an embedded flow please refer to + the webflow-primefaces-showcase project. You can check out + the source code locally, build it as you would a Maven project, and import + it into Eclipse: + + cd some-directory svn co https://src.springframework.org/svn/spring-samples/webflow-primefaces-showcase cd webflow-primefaces-showcase mvn package # import into Eclipse - The specific example you need to look at is under the "Advanced Ajax" - tab and is called "Top Flow with Embedded Sub-Flow". + The specific example you need to look at is under the "Advanced Ajax" + tab and is called "Top Flow with Embedded Sub-Flow". - + - - Redirect In Same State + + Redirect In Same State - - By default Web Flow does a client-side redirect even it it remains in the same view state as long as the current request is not an Ajax request. - This is quite useful after form validation failures for example. - If the user hits Refresh or Back they won't see any browser warnings. - They would if the Web Flow didn't do a redirect. - - - This can lead to a problem specific to JSF environments where a specific Sun Mojarra listener component caches the FacesContext assuming the same instance is available throughout the JSF lifecycle. - In Web Flow however the render phase is temporarily put on hold and a client-side redirect executed. - - - The default behavior of Web Flow is desirable and it is unlikely JSF applications will experience the issue. - This is because Ajax is often enabled the default in JSF component libraries and Web Flow does not redirect during Ajax requests. - However if you experience this issue you can disable client-side redirects within the same view as follows: - + + By default Web Flow does a client-side redirect even it it remains in the same view state as long as the current request is not an Ajax request. + This is quite useful after form validation failures for example. + If the user hits Refresh or Back they won't see any browser warnings. + They would if the Web Flow didn't do a redirect. + + + This can lead to a problem specific to JSF environments where a specific Sun Mojarra listener component caches the FacesContext assuming the same instance is available throughout the JSF lifecycle. + In Web Flow however the render phase is temporarily put on hold and a client-side redirect executed. + + + The default behavior of Web Flow is desirable and it is unlikely JSF applications will experience the issue. + This is because Ajax is often enabled the default in JSF component libraries and Web Flow does not redirect during Ajax requests. + However if you experience this issue you can disable client-side redirects within the same view as follows: + <webflow:flow-executor id="flowExecutor"> <webflow:flow-execution-attributes> <webflow:redirect-in-same-state value="false"/> </webflow:flow-execution-attributes> </webflow:flow-executor> - - - + + + - - Using the Spring Security Facelets Tag Library + + Using the Spring Security Facelets Tag Library - To use the library you'll need to create a .taglib.xml - file and register it in web.xml. + To use the library you'll need to create a .taglib.xml + file and register it in web.xml. - Create the file - /WEB-INF/springsecurity.taglib.xml with the following - content: + Create the file + /WEB-INF/springsecurity.taglib.xml with the following + content: - + <?xml version="1.0"?> <!DOCTYPE facelet-taglib PUBLIC - "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" - "http://java.sun.com/dtd/facelet-taglib_1_0.dtd"> +"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" +"http://java.sun.com/dtd/facelet-taglib_1_0.dtd"> <facelet-taglib> <namespace>http://www.springframework.org/security/tags</namespace> <tag> @@ -737,20 +741,20 @@ mvn package <function-signature>boolean isAllowed(java.lang.String, java.lang.String)</function-signature> </function> </facelet-taglib> - + - Next, register the above file taglib in web.xml: + Next, register the above file taglib in web.xml: - <context-param> - <param-name>javax.faces.FACELETS_LIBRARIES</param-name> - <param-value>/WEB-INF/springsecurity.taglib.xml</param-value> + <context-param> + <param-name>javax.faces.FACELETS_LIBRARIES</param-name> + <param-value>/WEB-INF/springsecurity.taglib.xml</param-value> </context-param> - + - Now you are ready to use the tag library in your views. You can use - the authorize tag to include nested content conditionally: + Now you are ready to use the tag library in your views. You can use + the authorize tag to include nested content conditionally: - <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" @@ -768,45 +772,45 @@ mvn package Lorem ipsum dolor sit amet </sec:authorize> -</ui:composition> - +</ui:composition> + - You can also use one of several EL functions in the rendered or - other attribute of any JSF component: + You can also use one of several EL functions in the rendered or + other attribute of any JSF component: - <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:sec="http://www.springframework.org/security/tags"> <!-- Rendered only if user has all of the listed roles --> - <h:outputText value="Lorem ipsum dolor sit amet" rendered="#{sec:areAllGranted('ROLE_FOO, ROLE_BAR')}"/> - + <h:outputText value="Lorem ipsum dolor sit amet" rendered="#{sec:areAllGranted('ROLE_FOO, ROLE_BAR')}"/> + <!-- Rendered only if user does not have any of the listed roles --> - <h:outputText value="Lorem ipsum dolor sit amet" rendered="#{sec:areNotGranted('ROLE_FOO, ROLE_BAR')}"/> - + <h:outputText value="Lorem ipsum dolor sit amet" rendered="#{sec:areNotGranted('ROLE_FOO, ROLE_BAR')}"/> + <!-- Rendered only if user has any of the listed roles --> - <h:outputText value="Lorem ipsum dolor sit amet" rendered="#{sec:areAnyGranted('ROLE_FOO, ROLE_BAR')}"/> - + <h:outputText value="Lorem ipsum dolor sit amet" rendered="#{sec:areAnyGranted('ROLE_FOO, ROLE_BAR')}"/> + <!-- Rendered only if user has access to given HTTP method/URL as defined in Spring Security configuration --> - <h:outputText value="Lorem ipsum dolor sit amet" rendered="#{sec:isAllowed('/secured/foo', 'POST')}"/> + <h:outputText value="Lorem ipsum dolor sit amet" rendered="#{sec:isAllowed('/secured/foo', 'POST')}"/> -</ui:composition> - - +</ui:composition> + + - - Third-Party Component Library Integration + + Third-Party Component Library Integration - The Spring Web Flow JSF integration strives to be compatible with - any third-party JSF component library. By honoring all of the standard - semantics of the JSF specification within the SWF-driven JSF lifecycle, - third-party libraries in general should "just work". The main thing to - remember is that configuration in web.xml will change slightly since Web - Flow requests are not routed through the standard FacesServlet. Typically, - anything that is traditionally mapped to the FacesServlet should be mapped - to the Spring DispatcherServlet instead. (You can also map to both if for - example you are migrating a legacy JSF application page-by-page.). - + The Spring Web Flow JSF integration strives to be compatible with + any third-party JSF component library. By honoring all of the standard + semantics of the JSF specification within the SWF-driven JSF lifecycle, + third-party libraries in general should "just work". The main thing to + remember is that configuration in web.xml will change slightly since Web + Flow requests are not routed through the standard FacesServlet. Typically, + anything that is traditionally mapped to the FacesServlet should be mapped + to the Spring DispatcherServlet instead. (You can also map to both if for + example you are migrating a legacy JSF application page-by-page.). + diff --git a/src/reference/spring-js.xml b/src/reference/spring-js.xml index 9d9a0471..4a441788 100644 --- a/src/reference/spring-js.xml +++ b/src/reference/spring-js.xml @@ -1,50 +1,54 @@ - - Spring JavaScript Quick Reference - - Introduction - - Spring Javascript (spring-js) is a lightweight abstraction over common JavaScript toolkits such as Dojo. - It aims to provide a common client-side programming model for progressively enhancing a web page with rich widget behavior and Ajax remoting. - - - Use of the Spring JS API is demonstrated in the the Spring MVC + Web Flow version of the Spring Travel reference application. - - - + + Spring JavaScript Quick Reference + + Introduction + + Spring Javascript (spring-js) is a lightweight abstraction over common JavaScript toolkits such as Dojo. + It aims to provide a common client-side programming model for progressively enhancing a web page with rich widget behavior and Ajax remoting. + + + Use of the Spring JS API is demonstrated in the the Spring MVC + Web Flow version of the Spring Travel reference application. + + + Serving Javascript Resources - Spring JS provides a generic ResourceServlet to serve web resources such as JavaScript and CSS files from jar files, - as well as the webapp root directory. - This servlet provides a convenient way to serve Spring.js files to your pages. - To deploy this servlet, declare the following in web.xml: - - ResourceServlet to serve web resources such as JavaScript and CSS files from jar files, + as well as the webapp root directory. + This servlet provides a convenient way to serve Spring.js files to your pages. + To deploy this servlet, declare the following in web.xml: + + - Resource Servlet - org.springframework.js.resource.ResourceServlet + Resource Servlet + org.springframework.js.resource.ResourceServlet - + - Resource Servlet - /resources/* + Resource Servlet + /resources/* ]]> - - + + Note that starting with version 3.0.4, the Spring Framework includes - a replacement for the ResourceServlet (see the - Spring Framework documentation). - With the new <mvc:resources> element resource requests (.js, .css) are handled by the - DispatcherSevlet without the need for a separate ResourceServlet. - Here is the relevant portion of the Spring MVC configuration in - the mvc-booking sample: - - ResourceServlet (see the + Spring Framework documentation). + With the new <mvc:resources> element resource requests (.js, .css) are handled by the + DispatcherSevlet without the need for a separate ResourceServlet. + Here is the relevant portion of the Spring MVC configuration in + the mvc-booking sample: + + ... - - + + ]]> - - - This incoming maps requests for /resources to resources found under - /META-INF/web-resources on the classpath. That's where Spring JavaScript resources - are bundled. However, you can modify the location attribute in the above configuration in order - to serve resources from any classpath or web application relative location. - - - Note that the full resource URL depends on how your DispatcherServlet is mapped. - In the mvc-booking sample we've chosen to map it with the default servlet mapping '/': - - + + This incoming maps requests for /resources to resources found under + /META-INF/web-resources on the classpath. That's where Spring JavaScript resources + are bundled. However, you can modify the location attribute in the above configuration in order + to serve resources from any classpath or web application relative location. + + + Note that the full resource URL depends on how your DispatcherServlet is mapped. + In the mvc-booking sample we've chosen to map it with the default servlet mapping '/': + + Spring MVC Dispatcher Servlet org.springframework.web.servlet.DispatcherServlet @@ -82,18 +86,18 @@ / ]]> - + That means the full URL to load Spring.js is /myapp/resources/spring/Spring.js. If your DispatcherServlet was instead mapped to /main/* then the full URL would be /myapp/main/resources/spring/Spring.js. - - - When using of the default servlet mapping it is also recommended to add this to your Spring MVC - configuration, which ensures that any resource requests not handled by your Spring MVC mappings - will be delegated back to the Servlet container. - - + + When using of the default servlet mapping it is also recommended to add this to your Spring MVC + configuration, which ensures that any resource requests not handled by your Spring MVC mappings + will be delegated back to the Servlet container. + + - - + + ]]> - - - - Including Spring Javascript in a Page - - Spring JS is designed such that an implementation of its API can be built for any of the popular Javascript toolkits. - The initial implementation of Spring.js builds on the Dojo toolkit. - - - Using Spring Javascript in a page requires including the underlying toolkit as normal, - the Spring.js base interface file, and the Spring-(library implementation).js file for the underlying toolkit. - As an example, the following includes obtain the Dojo implementation of Spring.js using the ResourceServlet: - - + + + Including Spring Javascript in a Page + + Spring JS is designed such that an implementation of its API can be built for any of the popular Javascript toolkits. + The initial implementation of Spring.js builds on the Dojo toolkit. + + + Using Spring Javascript in a page requires including the underlying toolkit as normal, + the Spring.js base interface file, and the Spring-(library implementation).js file for the underlying toolkit. + As an example, the following includes obtain the Dojo implementation of Spring.js using the ResourceServlet: + + "> ]]> - - - When using the widget system of an underlying library, typically you must also include some CSS resources to obtain the desired look and feel. - For the booking-mvc reference application, Dojo's tundra.css is included: - - + + When using the widget system of an underlying library, typically you must also include some CSS resources to obtain the desired look and feel. + For the booking-mvc reference application, Dojo's tundra.css is included: + + " />]]> - - - - Spring Javascript Decorations - - A central concept in Spring Javascript is the notion of applying decorations to existing DOM nodes. - This technique is used to progressively enhance a web page such that the page will still be functional in a less capable browser. - The addDecoration method is used to apply decorations. - - - The following example illustrates enhancing a Spring MVC <form:input> tag with rich suggestion behavior: - - + + + Spring Javascript Decorations + + A central concept in Spring Javascript is the notion of applying decorations to existing DOM nodes. + This technique is used to progressively enhance a web page such that the page will still be functional in a less capable browser. + The addDecoration method is used to apply decorations. + + + The following example illustrates enhancing a Spring MVC <form:input> tag with rich suggestion behavior: + + ]]> - - - The ElementDecoration is used to apply rich widget behavior to an existing DOM node. - This decoration type does not aim to completely hide the underlying toolkit, so the toolkit's native widget type and attributes are used directly. - This approach allows you to use a common decoration model to integrate any widget from the underlying toolkit in a consistent manner. - See the booking-mvc reference application for more examples of applying decorations to do things from suggestions to client-side validation. - - - When using the ElementDecoration to apply widgets that have rich validation behavior, a common need is to prevent the form from being submitted to the server until validation passes. - This can be done with the ValidateAllDecoration: - - + + The ElementDecoration is used to apply rich widget behavior to an existing DOM node. + This decoration type does not aim to completely hide the underlying toolkit, so the toolkit's native widget type and attributes are used directly. + This approach allows you to use a common decoration model to integrate any widget from the underlying toolkit in a consistent manner. + See the booking-mvc reference application for more examples of applying decorations to do things from suggestions to client-side validation. + + + When using the ElementDecoration to apply widgets that have rich validation behavior, a common need is to prevent the form from being submitted to the server until validation passes. + This can be done with the ValidateAllDecoration: + + ]]> - - - This decorates the "Proceed" button with a special onclick event handler that fires the client side validators and does not allow the form to submit until they pass successfully. - - - An AjaxEventDecoration applies a client-side event listener that fires a remote Ajax request to the server. It also auto-registers a callback function to link in the response: - - + + This decorates the "Proceed" button with a special onclick event handler that fires the client side validators and does not allow the form to submit until they pass successfully. + + + An AjaxEventDecoration applies a client-side event listener that fires a remote Ajax request to the server. It also auto-registers a callback function to link in the response: + + Previous ]]> - - - This decorates the onclick event of the "Previous Results" link with an Ajax call, passing along a special parameter that specifies the fragment to be re-rendered in the response. - Note that this link would still be fully functional if Javascript was unavailable in the client. - (See for details on how this request is handled on the server.) - - - It is also possible to apply more than one decoration to an element. - The following example shows a button being decorated with Ajax and validate-all submit suppression: - - + + + This decorates the onclick event of the "Previous Results" link with an Ajax call, passing along a special parameter that specifies the fragment to be re-rendered in the response. + Note that this link would still be fully functional if Javascript was unavailable in the client. + (See for details on how this request is handled on the server.) + + + It is also possible to apply more than one decoration to an element. + The following example shows a button being decorated with Ajax and validate-all submit suppression: + + ]]> - - - It is also possible to apply a decoration to multiple elements in a single statement using Dojo's query API. - The following example decorates a set of checkbox elements as Dojo Checkbox widgets: - - + + It is also possible to apply a decoration to multiple elements in a single statement using Dojo's query API. + The following example decorates a set of checkbox elements as Dojo Checkbox widgets: + + ]]> - - - - Handling Ajax Requests - - Spring Javascript's client-side Ajax response handling is built upon the notion of receiving "fragments" back from the server. - These fragments are just standard HTML that is meant to replace portions of the existing page. - The key piece needed on the server is a way to determine which pieces of a full response need to be pulled out for partial rendering. - - - In order to be able to render partial fragments of a full response, the full response must be built using a - templating technology that allows the use of composition for constructing the response, and for the member - parts of the composition to be referenced and rendered individually. - Spring Javascript provides some simple Spring MVC extensions that make use of Tiles to achieve this. - The same technique could theoretically be used with any templating system supporting composition. - - - Spring Javascript's Ajax remoting functionality is built upon the notion that the core handling code for an - Ajax request should not differ from a standard browser request, thus no special knowledge of an Ajax request - is needed directly in the code and the same hanlder can be used for both styles of request. - - - Providing a Library-Specific AjaxHandler - - The key interface for integrating various Ajax libraries with the Ajax-aware behavior of Web Flow (such as not redirecting for a - partial page update) is org.springframework.js.AjaxHandler. A SpringJavascriptAjaxHandler is configured by default that is able to - detect an Ajax request submitted via the Spring JS client-side API and can respond appropriately in the case where a redirect is required. In - order to integrate a different Ajax library (be it a pure JavaScript library, or a higher-level abstraction such as an Ajax-capable JSF - component library), a custom AjaxHandler can be injected into the FlowHandlerAdapter or FlowController. - - - - Handling Ajax Requests with Spring MVC Controllers - - In order to handle Ajax requests with Spring MVC controllers, all that is needed is the configuration of - the provided Spring MVC extensions in your Spring application context for rendering the partial response - (note that these extensions require the use of Tiles for templating): - - + + + Handling Ajax Requests + + Spring Javascript's client-side Ajax response handling is built upon the notion of receiving "fragments" back from the server. + These fragments are just standard HTML that is meant to replace portions of the existing page. + The key piece needed on the server is a way to determine which pieces of a full response need to be pulled out for partial rendering. + + + In order to be able to render partial fragments of a full response, the full response must be built using a + templating technology that allows the use of composition for constructing the response, and for the member + parts of the composition to be referenced and rendered individually. + Spring Javascript provides some simple Spring MVC extensions that make use of Tiles to achieve this. + The same technique could theoretically be used with any templating system supporting composition. + + + Spring Javascript's Ajax remoting functionality is built upon the notion that the core handling code for an + Ajax request should not differ from a standard browser request, thus no special knowledge of an Ajax request + is needed directly in the code and the same hanlder can be used for both styles of request. + + + Providing a Library-Specific AjaxHandler + + The key interface for integrating various Ajax libraries with the Ajax-aware behavior of Web Flow (such as not redirecting for a + partial page update) is org.springframework.js.AjaxHandler. A SpringJavascriptAjaxHandler is configured by default that is able to + detect an Ajax request submitted via the Spring JS client-side API and can respond appropriately in the case where a redirect is required. In + order to integrate a different Ajax library (be it a pure JavaScript library, or a higher-level abstraction such as an Ajax-capable JSF + component library), a custom AjaxHandler can be injected into the FlowHandlerAdapter or FlowController. + + + + Handling Ajax Requests with Spring MVC Controllers + + In order to handle Ajax requests with Spring MVC controllers, all that is needed is the configuration of + the provided Spring MVC extensions in your Spring application context for rendering the partial response + (note that these extensions require the use of Tiles for templating): + + - + ]]> - - - This configures the AjaxUrlBasedViewResolver which in turn interprets Ajax requests and creates FlowAjaxTilesView objects to handle rendering of the appropriate fragments. - Note that FlowAjaxTilesView is capable of handling the rendering for both Web Flow and pure Spring MVC requests. - The fragments correspond to individual attributes of a Tiles view definition. For example, take the following Tiles view definition: - - + + This configures the AjaxUrlBasedViewResolver which in turn interprets Ajax requests and creates FlowAjaxTilesView objects to handle rendering of the appropriate fragments. + Note that FlowAjaxTilesView is capable of handling the rendering for both Web Flow and pure Spring MVC requests. + The fragments correspond to individual attributes of a Tiles view definition. For example, take the following Tiles view definition: + + - + - - + + ]]> - - - An Ajax request could specify the "body", "hotelSearchForm" or "bookingsTable" to be rendered as fragments in the request. - - - - Handling Ajax Requests with Spring MVC + Spring Web Flow - - Spring Web Flow handles the optional rendering of fragments directly in the flow definition language through use of the render element. - The benefit of this approach is that the selection of fragments is completely decoupled from client-side code, such that no special parameters need to be passed with the request the way they - currently must be with the pure Spring MVC controller approach. - For example, if you wanted to render the "hotelSearchForm" fragment from the previous example Tiles view into a rich Javascript popup: - - + + An Ajax request could specify the "body", "hotelSearchForm" or "bookingsTable" to be rendered as fragments in the request. + + + + Handling Ajax Requests with Spring MVC + Spring Web Flow + + Spring Web Flow handles the optional rendering of fragments directly in the flow definition language through use of the render element. + The benefit of this approach is that the selection of fragments is completely decoupled from client-side code, such that no special parameters need to be passed with the request the way they + currently must be with the pure Spring MVC controller approach. + For example, if you wanted to render the "hotelSearchForm" fragment from the previous example Tiles view into a rich Javascript popup: + + - - - - - - -]]> - - - + + + + + + +]]> + + + diff --git a/src/reference/spring-mvc.xml b/src/reference/spring-mvc.xml index 3dd7623a..31bcafaf 100644 --- a/src/reference/spring-mvc.xml +++ b/src/reference/spring-mvc.xml @@ -1,499 +1,503 @@ - - Spring MVC Integration + +Spring MVC Integration - - Introduction + + Introduction - This chapter shows how to integrate Web Flow into a Spring MVC web - application. The booking-mvc sample application is a good - reference for Spring MVC with Web Flow. This application is a simplified - travel site that allows users to search for and book hotel rooms. - + This chapter shows how to integrate Web Flow into a Spring MVC web + application. The booking-mvc sample application is a good + reference for Spring MVC with Web Flow. This application is a simplified + travel site that allows users to search for and book hotel rooms. + - - Configuring web.xml + + Configuring web.xml - The first step to using Spring MVC is to configure the - DispatcherServlet in web.xml. You typically do - this once per web application. + The first step to using Spring MVC is to configure the + DispatcherServlet in web.xml. You typically do + this once per web application. - The example below maps all requests that begin with - /spring/ to the DispatcherServlet. An init-param - is used to provide the contextConfigLocation. This is the - configuration file for the web application. + The example below maps all requests that begin with + /spring/ to the DispatcherServlet. An init-param + is used to provide the contextConfigLocation. This is the + configuration file for the web application. - + <servlet> - <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> - <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> - <init-param> - <param-name>contextConfigLocation</param-name> - <param-value>/WEB-INF/web-application-config.xml</param-value> - </init-param> + <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> + <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> + <init-param> + <param-name>contextConfigLocation</param-name> + <param-value>/WEB-INF/web-application-config.xml</param-value> + </init-param> </servlet> - + <servlet-mapping> - <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> - <url-pattern>/spring/*</url-pattern> + <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> + <url-pattern>/spring/*</url-pattern> </servlet-mapping> - + - - Dispatching to flows + + Dispatching to flows - The DispatcherServlet maps requests for application - resources to handlers. A flow is one type of handler. + The DispatcherServlet maps requests for application + resources to handlers. A flow is one type of handler. - - Registering the FlowHandlerAdapter + + Registering the FlowHandlerAdapter - The first step to dispatching requests to flows is to enable flow - handling within Spring MVC. To this, install the - FlowHandlerAdapter: + The first step to dispatching requests to flows is to enable flow + handling within Spring MVC. To this, install the + FlowHandlerAdapter: - + <!-- Enables FlowHandler URL mapping --> <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"> - <property name="flowExecutor" ref="flowExecutor" /> + <property name="flowExecutor" ref="flowExecutor" /> </bean> - + - - Defining flow mappings + + Defining flow mappings - Once flow handling is enabled, the next step is to map specific - application resources to your flows. The simplest way to do this is to - define a FlowHandlerMapping: + Once flow handling is enabled, the next step is to map specific + application resources to your flows. The simplest way to do this is to + define a FlowHandlerMapping: - + <!-- Maps request paths to flows in the flowRegistry; - e.g. a path of /hotels/booking looks for a flow with id "hotels/booking" --> + e.g. a path of /hotels/booking looks for a flow with id "hotels/booking" --> <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"> - <property name="flowRegistry" ref="flowRegistry"/> - <property name="order" value="0"/> + <property name="flowRegistry" ref="flowRegistry"/> + <property name="order" value="0"/> </bean> - Configuring this mapping allows the Dispatcher to map application - resource paths to flows in a flow registry. For example, accessing the - resource path /hotels/booking would result in a registry - query for the flow with id hotels/booking. If a flow is - found with that id, that flow will handle the request. If no flow is - found, the next handler mapping in the Dispatcher's ordered chain will - be queried or a "noHandlerFound" response will be returned. - + Configuring this mapping allows the Dispatcher to map application + resource paths to flows in a flow registry. For example, accessing the + resource path /hotels/booking would result in a registry + query for the flow with id hotels/booking. If a flow is + found with that id, that flow will handle the request. If no flow is + found, the next handler mapping in the Dispatcher's ordered chain will + be queried or a "noHandlerFound" response will be returned. + - - Flow handling workflow + + Flow handling workflow - When a valid flow mapping is found, the - FlowHandlerAdapter figures out whether to start a new - execution of that flow or resume an existing execution based on - information present the HTTP request. There are a number of defaults - related to starting and resuming flow executions the adapter - employs: + When a valid flow mapping is found, the + FlowHandlerAdapter figures out whether to start a new + execution of that flow or resume an existing execution based on + information present the HTTP request. There are a number of defaults + related to starting and resuming flow executions the adapter + employs: - - - HTTP request parameters are made available in the input map of - all starting flow executions. - + + + HTTP request parameters are made available in the input map of + all starting flow executions. + - - When a flow execution ends without sending a final response, - the default handler will attempt to start a new execution in the - same request. - + + When a flow execution ends without sending a final response, + the default handler will attempt to start a new execution in the + same request. + - - Unhandled exceptions are propagated to the Dispatcher unless - the exception is a NoSuchFlowExecutionException. The default handler - will attempt to recover from a NoSuchFlowExecutionException by - starting over a new execution. - - + + Unhandled exceptions are propagated to the Dispatcher unless + the exception is a NoSuchFlowExecutionException. The default handler + will attempt to recover from a NoSuchFlowExecutionException by + starting over a new execution. + + - Consult the API documentation for FlowHandlerAdapter - for more information. You may override these defaults by subclassing or - by implementing your own FlowHandler, discussed in the next - section. - - + Consult the API documentation for FlowHandlerAdapter + for more information. You may override these defaults by subclassing or + by implementing your own FlowHandler, discussed in the next + section. + + - - Implementing custom FlowHandlers + + Implementing custom FlowHandlers - FlowHandler is the extension point that can be used to - customize how flows are executed in a HTTP servlet environment. A - FlowHandler is used by the FlowHandlerAdapter - and is responsible for: + FlowHandler is the extension point that can be used to + customize how flows are executed in a HTTP servlet environment. A + FlowHandler is used by the FlowHandlerAdapter + and is responsible for: - - - Returning the id of a flow definition to - execute - + + + Returning the id of a flow definition to + execute + - - Creating the input to pass new executions of that flow as they - are started - + + Creating the input to pass new executions of that flow as they + are started + - - Handling outcomes returned by executions of that flow as they - end - + + Handling outcomes returned by executions of that flow as they + end + - - Handling any exceptions thrown by executions of that flow as - they occur - - + + Handling any exceptions thrown by executions of that flow as + they occur + + - These responsibilities are illustrated in the definition of the - org.springframework.mvc.servlet.FlowHandler interface: + These responsibilities are illustrated in the definition of the + org.springframework.mvc.servlet.FlowHandler interface: - + public interface FlowHandler { - public String getFlowId(); + public String getFlowId(); - public MutableAttributeMap createExecutionInputMap(HttpServletRequest request); + public MutableAttributeMap createExecutionInputMap(HttpServletRequest request); - public String handleExecutionOutcome(FlowExecutionOutcome outcome, - HttpServletRequest request, HttpServletResponse response); + public String handleExecutionOutcome(FlowExecutionOutcome outcome, + HttpServletRequest request, HttpServletResponse response); - public String handleException(FlowException e, - HttpServletRequest request, HttpServletResponse response); -} + public String handleException(FlowException e, + HttpServletRequest request, HttpServletResponse response); +} - To implement a FlowHandler, subclass - AbstractFlowHandler. All these operations are optional, and - if not implemented the defaults will apply. You only need to override the - methods that you need. Specifically: + To implement a FlowHandler, subclass + AbstractFlowHandler. All these operations are optional, and + if not implemented the defaults will apply. You only need to override the + methods that you need. Specifically: - - - Override getFlowId(HttpServletRequest) when the id - of your flow cannot be directly derived from the HTTP request. By - default, the id of the flow to execute is derived from the pathInfo - portion of the request URI. For example, - http://localhost/app/hotels/booking?hotelId=1 results in - a flow id of hotels/booking by default. - + + + Override getFlowId(HttpServletRequest) when the id + of your flow cannot be directly derived from the HTTP request. By + default, the id of the flow to execute is derived from the pathInfo + portion of the request URI. For example, + http://localhost/app/hotels/booking?hotelId=1 results in + a flow id of hotels/booking by default. + - - Override - createExecutionInputMap(HttpServletRequest) when you need - fine-grained control over extracting flow input parameters from the - HttpServletRequest. By default, all request parameters are treated as - flow input parameters. - + + Override + createExecutionInputMap(HttpServletRequest) when you need + fine-grained control over extracting flow input parameters from the + HttpServletRequest. By default, all request parameters are treated as + flow input parameters. + - - Override handleExecutionOutcome when you need to - handle specific flow execution outcomes in a custom manner. The - default behavior sends a redirect to the ended flow's URL to restart a - new execution of the flow. - + + Override handleExecutionOutcome when you need to + handle specific flow execution outcomes in a custom manner. The + default behavior sends a redirect to the ended flow's URL to restart a + new execution of the flow. + - - Override handleException when you need fine-grained - control over unhandled flow exceptions. The default behavior attempts - to restart the flow when a client attempts to access an ended or - expired flow execution. Any other exception is rethrown to the Spring - MVC ExceptionResolver infrastructure by default. - - + + Override handleException when you need fine-grained + control over unhandled flow exceptions. The default behavior attempts + to restart the flow when a client attempts to access an ended or + expired flow execution. Any other exception is rethrown to the Spring + MVC ExceptionResolver infrastructure by default. + + - - Example FlowHandler + + Example FlowHandler - A common interaction pattern between Spring MVC And Web Flow is - for a Flow to redirect to a @Controller when it ends. FlowHandlers allow - this to be done without coupling the flow definition itself with a - specific controller URL. An example FlowHandler that redirects to a - Spring MVC Controller is shown below: + A common interaction pattern between Spring MVC And Web Flow is + for a Flow to redirect to a @Controller when it ends. FlowHandlers allow + this to be done without coupling the flow definition itself with a + specific controller URL. An example FlowHandler that redirects to a + Spring MVC Controller is shown below: - + public class BookingFlowHandler extends AbstractFlowHandler { - public String handleExecutionOutcome(FlowExecutionOutcome outcome, - HttpServletRequest request, HttpServletResponse response) { - if (outcome.getId().equals("bookingConfirmed")) { - return "/booking/show?bookingId=" + outcome.getOutput().get("bookingId"); - } else { - return "/hotels/index"; - } - } + public String handleExecutionOutcome(FlowExecutionOutcome outcome, + HttpServletRequest request, HttpServletResponse response) { + if (outcome.getId().equals("bookingConfirmed")) { + return "/booking/show?bookingId=" + outcome.getOutput().get("bookingId"); + } else { + return "/hotels/index"; + } + } } - Since this handler only needs to handle flow execution outcomes in - a custom manner, nothing else is overridden. The - bookingConfirmed outcome will result in a redirect to show - the new booking. Any other outcome will redirect back to the hotels - index page. - + Since this handler only needs to handle flow execution outcomes in + a custom manner, nothing else is overridden. The + bookingConfirmed outcome will result in a redirect to show + the new booking. Any other outcome will redirect back to the hotels + index page. + - - Deploying a custom FlowHandler + + Deploying a custom FlowHandler - To install a custom FlowHandler, simply deploy it as a bean. The - bean name must match the id of the flow the handler should apply - to. + To install a custom FlowHandler, simply deploy it as a bean. The + bean name must match the id of the flow the handler should apply + to. - + <bean name="hotels/booking" class="org.springframework.webflow.samples.booking.BookingFlowHandler" /> - With this configuration, accessing the resource - /hotels/booking will launch the hotels/booking - flow using the custom BookingFlowHandler. When the booking flow ends, - the FlowHandler will process the flow execution outcome and redirect to - the appropriate controller. - + With this configuration, accessing the resource + /hotels/booking will launch the hotels/booking + flow using the custom BookingFlowHandler. When the booking flow ends, + the FlowHandler will process the flow execution outcome and redirect to + the appropriate controller. + - - FlowHandler Redirects + + FlowHandler Redirects - A FlowHandler handling a FlowExecutionOutcome or FlowException - returns a String to indicate the resource to redirect to - after handling. In the previous example, the - BookingFlowHandler redirects to the - booking/show resource URI for bookingConfirmed - outcomes, and the hotels/index resource URI for all other - outcomes. + A FlowHandler handling a FlowExecutionOutcome or FlowException + returns a String to indicate the resource to redirect to + after handling. In the previous example, the + BookingFlowHandler redirects to the + booking/show resource URI for bookingConfirmed + outcomes, and the hotels/index resource URI for all other + outcomes. - By default, returned resource locations are relative to the - current servlet mapping. This allows for a flow handler to redirect to - other Controllers in the application using relative paths. In addition, - explicit redirect prefixes are supported for cases where more control is - needed. + By default, returned resource locations are relative to the + current servlet mapping. This allows for a flow handler to redirect to + other Controllers in the application using relative paths. In addition, + explicit redirect prefixes are supported for cases where more control is + needed. - The explicit redirect prefixes supported are: + The explicit redirect prefixes supported are: - - - servletRelative: - redirect to a resource - relative to the current servlet - + + + servletRelative: - redirect to a resource + relative to the current servlet + - - contextRelative: - redirect to a resource - relative to the current web application context path - + + contextRelative: - redirect to a resource + relative to the current web application context path + - - serverRelative: - redirect to a resource relative - to the server root - + + serverRelative: - redirect to a resource relative + to the server root + - - http:// or https:// - redirect to a - fully-qualified resource URI - - + + http:// or https:// - redirect to a + fully-qualified resource URI + + - These same redirect prefixes are also supported within a flow - definition when using the externalRedirect: directive in - conjunction with a view-state or end-state; for example, - view="externalRedirect:http://springframework.org" - - + These same redirect prefixes are also supported within a flow + definition when using the externalRedirect: directive in + conjunction with a view-state or end-state; for example, + view="externalRedirect:http://springframework.org" + + - - View Resolution + + View Resolution - Web Flow 2 maps selected view identifiers to files located within - the flow's working directory unless otherwise specified. For existing - Spring MVC + Web Flow applications, an external ViewResolver - is likely already handling this mapping for you. Therefore, to continue - using that resolver and to avoid having to change how your existing flow - views are packaged, configure Web Flow as follows: + Web Flow 2 maps selected view identifiers to files located within + the flow's working directory unless otherwise specified. For existing + Spring MVC + Web Flow applications, an external ViewResolver + is likely already handling this mapping for you. Therefore, to continue + using that resolver and to avoid having to change how your existing flow + views are packaged, configure Web Flow as follows: - + <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"> - <webflow:location path="/WEB-INF/hotels/booking/booking.xml" /> + <webflow:location path="/WEB-INF/hotels/booking/booking.xml" /> </webflow:flow-registry> <webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="mvcViewFactoryCreator"/> <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"> - <property name="viewResolvers" ref="myExistingViewResolverToUseForFlows"/> + <property name="viewResolvers" ref="myExistingViewResolverToUseForFlows"/> </bean> - The MvcViewFactoryCreator is the factory that allows you to - configure how the Spring MVC view system is used inside Spring Web Flow. - Use it to configure existing ViewResolvers, as well as other services such - as a custom MessageCodesResolver. You may also enable data binding use - Spring MVC's native BeanWrapper by setting the - useSpringBinding flag to true. This is an alternative to - using OGNL or the Unified EL for view-to-model data binding. See the - JavaDoc API of this class for more information. - + The MvcViewFactoryCreator is the factory that allows you to + configure how the Spring MVC view system is used inside Spring Web Flow. + Use it to configure existing ViewResolvers, as well as other services such + as a custom MessageCodesResolver. You may also enable data binding use + Spring MVC's native BeanWrapper by setting the + useSpringBinding flag to true. This is an alternative to + using OGNL or the Unified EL for view-to-model data binding. See the + JavaDoc API of this class for more information. + - - Signaling an event from a View + + Signaling an event from a View - When a flow enters a view-state it pauses, redirects the user to its - execution URL, and waits for a user event to resume. Events are generally - signaled by activating buttons, links, or other user interface commands. - How events are decoded server-side is specific to the view technology in - use. This section shows how to trigger events from HTML-based views - generated by templating engines such as JSP, Velocity, or - Freemarker. + When a flow enters a view-state it pauses, redirects the user to its + execution URL, and waits for a user event to resume. Events are generally + signaled by activating buttons, links, or other user interface commands. + How events are decoded server-side is specific to the view technology in + use. This section shows how to trigger events from HTML-based views + generated by templating engines such as JSP, Velocity, or + Freemarker. - - Using a named HTML button to signal an event + + Using a named HTML button to signal an event - The example below shows two buttons on the same form that signal - proceed and cancel events when clicked, - respectively. + The example below shows two buttons on the same form that signal + proceed and cancel events when clicked, + respectively. - + <input type="submit" name="_eventId_proceed" value="Proceed" /> -<input type="submit" name="_eventId_cancel" value="Cancel" /> +<input type="submit" name="_eventId_cancel" value="Cancel" /> - When a button is pressed Web Flow finds a request parameter name - beginning with _eventId_ and treats the remaining substring - as the event id. So in this example, submitting - _eventId_proceed becomes proceed. This style - should be considered when there are several different events that can be - signaled from the same form. - + When a button is pressed Web Flow finds a request parameter name + beginning with _eventId_ and treats the remaining substring + as the event id. So in this example, submitting + _eventId_proceed becomes proceed. This style + should be considered when there are several different events that can be + signaled from the same form. + - - Using a hidden HTML form parameter to signal an event + + Using a hidden HTML form parameter to signal an event - The example below shows a form that signals the - proceed event when submitted: + The example below shows a form that signals the + proceed event when submitted: - + <input type="submit" value="Proceed" /> -<input type="hidden" name="_eventId" value="proceed" /> +<input type="hidden" name="_eventId" value="proceed" /> - Here, Web Flow simply detects the special _eventId - parameter and uses its value as the event id. This style should only be - considered when there is one event that can be signaled on the - form. - + Here, Web Flow simply detects the special _eventId + parameter and uses its value as the event id. This style should only be + considered when there is one event that can be signaled on the + form. + - - Using a HTML link to signal an event + + Using a HTML link to signal an event - The example below shows a link that signals the - cancel event when activated: + The example below shows a link that signals the + cancel event when activated: - -<a href="${flowExecutionUrl}&_eventId=cancel">Cancel</a> + +<a href="${flowExecutionUrl}&_eventId=cancel">Cancel</a> - Firing an event results in a HTTP request being sent back to the - server. On the server-side, the flow handles decoding the event from - within its current view-state. How this decoding process works is - specific to the view implementation. Recall a Spring MVC view - implementation simply looks for a request parameter named - _eventId. If no _eventId parameter is found, - the view will look for a parameter that starts with - _eventId_ and will use the remaining substring as the event - id. If neither cases exist, no flow event is triggered. - - + Firing an event results in a HTTP request being sent back to the + server. On the server-side, the flow handles decoding the event from + within its current view-state. How this decoding process works is + specific to the view implementation. Recall a Spring MVC view + implementation simply looks for a request parameter named + _eventId. If no _eventId parameter is found, + the view will look for a parameter that starts with + _eventId_ and will use the remaining substring as the event + id. If neither cases exist, no flow event is triggered. + + - - Embedding A Flow On A Page + + Embedding A Flow On A Page - By default when a flow enters a view state, it executes a - client-side redirect before rendering the view. This approach is known as - POST-REDIRECT-GET. It has the advantage of separating the form processing - for one view from the rendering of the next view. As a result the browser - Back and Refresh buttons work seamlessly without causing any browser - warnings. + By default when a flow enters a view state, it executes a + client-side redirect before rendering the view. This approach is known as + POST-REDIRECT-GET. It has the advantage of separating the form processing + for one view from the rendering of the next view. As a result the browser + Back and Refresh buttons work seamlessly without causing any browser + warnings. - Normally the client-side redirect is transparent from a user's - perspective. However, there are situations where POST-REDIRECT-GET may not - bring the same benefits. For example a flow may be embedded on a page and driven via - Ajax requests refreshing only the area of the page that belongs to the flow. - Not only is it unnecessary to use client-side redirects in this case, it - is also not the desired behavior with regards to keeping the surrounding - content of the page intact. + Normally the client-side redirect is transparent from a user's + perspective. However, there are situations where POST-REDIRECT-GET may not + bring the same benefits. For example a flow may be embedded on a page and driven via + Ajax requests refreshing only the area of the page that belongs to the flow. + Not only is it unnecessary to use client-side redirects in this case, it + is also not the desired behavior with regards to keeping the surrounding + content of the page intact. - The explains how to do - partial rendering during Ajax requests. The focus of this section is to - explain how to control flow execution redirect behavior during - Ajax requests. To indicate a flow should execute in "page embedded" mode all - you need to do is append an extra parameter when launching the - flow: + The explains how to do + partial rendering during Ajax requests. The focus of this section is to + explain how to control flow execution redirect behavior during + Ajax requests. To indicate a flow should execute in "page embedded" mode all + you need to do is append an extra parameter when launching the + flow: - /hotels/booking?mode=embedded + /hotels/booking?mode=embedded - When launched in "page embedded" mode a flow will not issue - flow execution redirects during Ajax requests. The mode=embedded parameter - only needs to be passed when launching the flow. Your only other concern is - to use Ajax requests and to render only the content required to update - the portion of the page displaying the flow. + When launched in "page embedded" mode a flow will not issue + flow execution redirects during Ajax requests. The mode=embedded parameter + only needs to be passed when launching the flow. Your only other concern is + to use Ajax requests and to render only the content required to update + the portion of the page displaying the flow. - + Embedded Mode Vs Default Redirect Behavior By default Web Flow does a client-side redirect upon entering every view state. However if you remain in the same view state -- for example a transition without a "to" attribute -- during an Ajax request there will not be a client-side redirect. This behavior should be quite familiar to Spring Web Flow 2 users. It is appropriate for a top-level flow that supports the browser back button while still taking advantage of Ajax and partial rendering for use cases where you remain in the same view such as form validation, paging trough search results, and others. - However transitions to a new view state are always followed with a client-side redirect. - That makes it impossible to embed a flow on a page or within a modal dialog and execute more than one view state without causing a full-page refresh. + However transitions to a new view state are always followed with a client-side redirect. + That makes it impossible to embed a flow on a page or within a modal dialog and execute more than one view state without causing a full-page refresh. Hence if your use case requires embedding a flow you can launch it in "embedded" mode. - + Embedded Flow Examples - If you'd like to see examples of a flow embedded on a page and within - a modal dialog please refer to the webflow-showcase project. You can check out - the source code locally, build it as you would a Maven project, and import - it into Eclipse: - - cd some-directory + If you'd like to see examples of a flow embedded on a page and within + a modal dialog please refer to the webflow-showcase project. You can check out + the source code locally, build it as you would a Maven project, and import + it into Eclipse: + + cd some-directory svn co https://src.springframework.org/svn/spring-samples/webflow-showcase cd webflow-showcase mvn package # import into Eclipse - + - - Saving Flow Output to MVC Flash Scope - Flow output can be automatically saved to MVC flash scope when an end-state - performs an internal redirect. This is particularly useful when displaying a summary - screen at the end of a flow. For backwards compatibility this feature is disabled by - default, to enable set saveOutputToFlashScopeOnRedirect on your - FlowHandlerAdapter to true. + + Saving Flow Output to MVC Flash Scope + Flow output can be automatically saved to MVC flash scope when an end-state + performs an internal redirect. This is particularly useful when displaying a summary + screen at the end of a flow. For backwards compatibility this feature is disabled by + default, to enable set saveOutputToFlashScopeOnRedirect on your + FlowHandlerAdapter to true. - + <!-- Enables FlowHandler URL mapping --> <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"> - <property name="flowExecutor" ref="flowExecutor" /> - <property name="saveOutputToFlashScopeOnRedirect" value="true" /> + <property name="flowExecutor" ref="flowExecutor" /> + <property name="saveOutputToFlashScopeOnRedirect" value="true" /> </bean> - + - The following example will add confirmationNumber to the MVC flash scope - before redirecting to the summary screen. + The following example will add confirmationNumber to the MVC flash scope + before redirecting to the summary screen. - + <end-state id="finish" view="externalRedirect:summary"> - <output name="confirmationNumber" value="booking.confirmationNumber" /> + <output name="confirmationNumber" value="booking.confirmationNumber" /> </end-state> - - + + diff --git a/src/reference/system-setup.xml b/src/reference/system-setup.xml index d8604919..94b19677 100644 --- a/src/reference/system-setup.xml +++ b/src/reference/system-setup.xml @@ -1,16 +1,20 @@ - + System Setup - + Introduction This chapter shows you how to setup the Web Flow system for use in any web environment. - + webflow-config.xsd Web Flow provides a Spring schema that allows you to configure the system. @@ -24,19 +28,19 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/webflow-config - http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd"> + http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd"> - + ]]> - + Basic system configuration The next section shows the minimal configuration required to set up the Web Flow system in your application. - + FlowRegistry Register your flows in a FlowRegistry: @@ -47,7 +51,7 @@ ]]> - + FlowExecutor Deploy a FlowExecutor, the central service for executing flows: @@ -60,12 +64,12 @@ - + flow-registry options This section explores flow-registry configuration options. - + Specifying flow locations Use the location element to specify paths to flow definitions to register. @@ -74,8 +78,8 @@ ]]> - - + + Assigning custom flow identifiers Specify an id to assign a custom registry identifier to a flow: @@ -84,7 +88,7 @@ ]]> - + Assigning flow meta-attributes Use the flow-definition-attributes element to assign custom meta-attributes to a registered flow: @@ -97,7 +101,7 @@ ]]> - + Registering flows using a location pattern Use the flow-location-patterns element to register flows that match a specific resource location pattern: @@ -106,7 +110,7 @@ ]]> - + Flow location base path Use the base-path attribute to define a base location for all flows in the application. @@ -150,7 +154,7 @@ you'd end up with flow ids of user/login, user/registration, hotels/booking, and flights/booking, respectively. - + Configuring FlowRegistry hierarchies Use the parent attribute to link two flow registries together in a hierarchy. @@ -167,8 +171,8 @@ ]]> - - + + Configuring custom FlowBuilder services Use the flow-builder-services attribute to customize the services and settings used to build flows in a flow-registry. @@ -196,7 +200,7 @@ ]]> - + conversion-service Use the conversion-service attribute to customize the ConversionService used by the Web Flow system. @@ -206,14 +210,14 @@ Please read for important information on how to provide custom type conversion logic. - + expression-parser Use the expression-parser attribute to customize the ExpressionParser used by the Web Flow system. - The default ExpressionParser uses the Unified EL if available on the classpath, otherwise OGNL is used. + The default ExpressionParser uses the Unified EL if available on the classpath, otherwise OGNL is used. - + view-factory-creator Use the view-factory-creator attribute to customize the ViewFactoryCreator used by the Web Flow system. @@ -224,7 +228,7 @@ These settings are global configuration attributes that can be applied during the flow construction process. - + development Set this to true to switch on flow development mode. @@ -233,12 +237,12 @@ - + flow-executor options This section explores flow-executor configuration options. - - + + Attaching flow execution listeners Use the flow-execution-listeners element to register listeners that observe the lifecycle of flow executions: @@ -256,7 +260,7 @@ ]]> - + Tuning FlowExecution persistence Use the flow-execution-repository element to tune flow execution persistence settings: @@ -266,23 +270,23 @@ ]]> - + max-executions Tune the max-executions attribute to place a cap on the number of flow executions that can be created per user session. When the maximum number of executions is exceeded, the oldest execution is removed. - The max-executions attribute is per user session, i.e. it works across instances of any flow definition. + The max-executions attribute is per user session, i.e. it works across instances of any flow definition. - + max-execution-snapshots Tune the max-execution-snapshots attribute to place a cap on the number of history snapshots that can be taken per flow execution. - To disable snapshotting, set this value to 0. To enable an unlimited number of snapshots, set this value to -1. + To disable snapshotting, set this value to 0. To enable an unlimited number of snapshots, set this value to -1. History snapshots enable browser back button support. diff --git a/src/reference/testing.xml b/src/reference/testing.xml index 08eeeb84..b27ceb44 100644 --- a/src/reference/testing.xml +++ b/src/reference/testing.xml @@ -1,16 +1,20 @@ - + Testing flows - + Introduction This chapter shows you how to test flows. - + Extending AbstractXmlFlowExecutionTests To test the execution of a XML-based flow definition, extend AbstractXmlFlowExecutionTests: @@ -21,7 +25,7 @@ public class BookingFlowExecutionTests extends AbstractXmlFlowExecutionTests { }]]> - + Specifying the path to the flow to test At a minimum, you must override getResource(FlowDefinitionResourceFactory) to return the path to the flow you wish to test: @@ -29,11 +33,11 @@ public class BookingFlowExecutionTests extends AbstractXmlFlowExecutionTests { - + Registering flow dependencies If your flow has dependencies on externally managed services, @@ -42,107 +46,107 @@ protected FlowDefinitionResource getResource(FlowDefinitionResourceFactory resou - - - If your flow extends from another flow, or has states that extend other states, - also override getModelResources(FlowDefinitionResourceFactory) to return the path to the parent flows. - + + + If your flow extends from another flow, or has states that extend other states, + also override getModelResources(FlowDefinitionResourceFactory) to return the path to the parent flows. + - + Testing flow startup - - Have your first test exercise the startup of your flow: - + + Have your first test exercise the startup of your flow: + - - - Assertions generally verify the flow is in the correct state you expect. - + + + Assertions generally verify the flow is in the correct state you expect. + - - Testing flow event handling - - Define additional tests to exercise flow event handling behavior. - You goal should be to exercise all paths through the flow. - You can use the convenient setCurrentState(String) method to jump to the flow state where you wish to begin your test. - - + Testing flow event handling + + Define additional tests to exercise flow event handling behavior. + You goal should be to exercise all paths through the flow. + You can use the convenient setCurrentState(String) method to jump to the flow state where you wish to begin your test. + + - - Mocking a subflow - - To test calling a subflow, register a mock implementation of the subflow that asserts input was passed in correctly and - returns the correct outcome for your test scenario. - + + Mocking a subflow + + To test calling a subflow, register a mock implementation of the subflow that asserts input was passed in correctly and + returns the correct outcome for your test scenario. + diff --git a/src/reference/upgrade-guide.xml b/src/reference/upgrade-guide.xml index caeb7d57..d0da31f1 100644 --- a/src/reference/upgrade-guide.xml +++ b/src/reference/upgrade-guide.xml @@ -1,16 +1,20 @@ - + Upgrading from 1.0 - + Introduction This chapter shows you how to upgrade existing Web Flow 1 application to Web Flow 2. - + Flow Definition Language The core concepts behind the flow definition language have not changed between Web Flow 1 and 2. @@ -18,7 +22,7 @@ These changes allow for the language to be both more concise and expressive. A complete list of mapping changes is available as an appendix. - + Flow Definition Updater Tool An automated tool is available to aid in the conversion of existing 1.x flows to the new 2.x style. @@ -28,7 +32,7 @@ The conversion tool requires spring-webflow.jar, spring-core.jar and an XSLT 1.0 engine. - Saxon 6.5.5 is recommended. + Saxon 6.5.5 is recommended. The tool can be run from the command line with the following command. @@ -39,9 +43,9 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml - + Flow Definition Updater Tool Warnings - + argument parameter-type no longer supported Bean actions have been deprecated in favor of EL based evaluate expressions. @@ -49,7 +53,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml A side effect of this change is that method arguments must be of the correct type before invoking the action. - + inline-flow is no longer supported Inline flows are no longer supported. @@ -57,21 +61,21 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml The inline flow's content has been converted for your convenience. - + mapping target-collection is no longer supported Output mappings can no longer add an item to a collection. Only assignment is supported. - + var bean is no longer supported The var bean attribute is no longer needed. - All spring beans can be resolved via EL. + All spring beans can be resolved via EL. - + var scope is no longer supported The var element will place all variable into flow scope. @@ -80,26 +84,26 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml - + EL Expressions EL expressions are used heavily throughout the flow definition language. Many of the attributes that appear to be plain text are actually interpreted as EL. - The standard EL delimiters (either ${} or #{} in Web Flow 2.0 or just #{} in Web Flow 2.1) are not necessary and will often cause an exception if they are included. + The standard EL delimiters (either ${} or #{} in Web Flow 2.0 or just #{} in Web Flow 2.1) are not necessary and will often cause an exception if they are included. EL delimiters should be removed where necessary by the updater tool. - + Web Flow Configuration In Web Flow 1 there were two options available for configuring Web Flow, one using standard spring bean XML and the other using the webflow-config-1.0 schema. The schema configuration option simplifies the configuration process by keeping long internal class names hidden and enabling contextual auto-complete. The schema configuration option is the only way to configure Web Flow 2. - + Web Flow Bean Configuration The FactoryBean bean XML configuration method used in Web Flow 1 is no longer supported. @@ -108,7 +112,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml Continue reading Web Flow Schema Configuration for details. - + Web Flow Schema Configuration The webflow-config configuration schema has also changed slightly from version 1 to 2. @@ -125,7 +129,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd"> ]]> - + flow-executor The flow executor is the core Web Flow configuration element. @@ -135,7 +139,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml ]]> - + flow-execution-listeners Flow execution listeners are also defined in the flow executor. @@ -152,7 +156,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml class="org.springframework.webflow.security.SecurityFlowExecutionListener" /> ]]> - + flow-registry The flow-registry contains a set of flow-locations. @@ -166,7 +170,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml ]]> - + Flow Controller The package name for flow controllers has changed from org.springframework.webflow.executor.mvc.FlowController and is now org.springframework.webflow.mvc.servlet.FlowController for Servlet MVC requests. @@ -174,7 +178,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml They will need to be updated in the bean definitions. - + Flow URL Handler The default URL handler has changed in Web Flow 2. @@ -190,7 +194,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml ]]> - + View Resolution Web Flow 2 by default will both select and render views. @@ -198,7 +202,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml In order for version 1 flows to work in Web Flow 2 the default view resolver must be overridden. - A common use case is to use Apache Tiles for view resolution. + A common use case is to use Apache Tiles for view resolution. The following configuration will replace the default view resolver with a Tiles view resolver. The tilesViewResolver in this example can be replaced with any other view resolver. @@ -208,7 +212,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml ... - @@ -225,9 +229,9 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml ]]> - + New Web Flow Concepts - + Automatic Model Binding Web Flow 1 required Spring MVC based flows to manually call FormAction methods, notably: @@ -236,7 +240,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml Please see the Binding to a Model section for details. - + OGNL vs Spring EL Web Flow 1 used OGNL exclusively for expressions within the flow definitions. @@ -246,7 +250,7 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml Please see for details. - + Flash Scope Flash scope in Web Flow 1 lived across the current request and into the next request. @@ -255,14 +259,14 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml This makes flashScope semantics in Web Flow consistent with other web frameworks. - + JSF Web Flow 2 offers significantly improved integration with JSF. Please see for details. - + External Redirects External redirects in Web Flow 1 were always considered context relative. diff --git a/src/reference/views.xml b/src/reference/views.xml index 501ab786..3fa17482 100644 --- a/src/reference/views.xml +++ b/src/reference/views.xml @@ -1,16 +1,20 @@ - + Rendering views - + Introduction This chapter shows you how to use the view-state element to render views within a flow. - + Defining view states Use the view-state element to define a step of the flow that renders a view and waits for a user event to resume: @@ -38,14 +42,14 @@ - + - + Specifying view identifiers Use the view attribute to specify the id of the view to render explicitly. - + Flow relative view ids The view id may be a relative path to view resource in the flow's working directory: @@ -54,7 +58,7 @@ ]]> - + Absolute view ids The view id may be a absolute path to a view resource in the webapp root directory: @@ -63,7 +67,7 @@ ]]> - + Logical view ids With some view frameworks, such as Spring MVC's view framework, the view id may also be a logical identifier resolved by the framework: @@ -76,7 +80,7 @@ - + View scope A view-state allocates a new viewScope when it enters. @@ -84,7 +88,7 @@ This scope is useful for manipulating objects over a series of requests from the same view, often Ajax requests. A view-state destroys its viewScope when it exits. - + Allocating view variables Use the var tag to declare a view variable. @@ -93,8 +97,8 @@ ]]> - - + + Assigning a viewScope variable Use the on-render tag to assign a variable from an action result before the view renders: @@ -105,11 +109,11 @@ ]]> - + Manipulating objects in view scope Objects in view scope are often manipulated over a series of requests from the same view. - The following example pages through a search results list. + The following example pages through a search results list. The list is updated in view scope before each render. Asynchronous event handlers modify the current data page, then request re-rendering of the search results fragment. @@ -121,17 +125,17 @@ - + - + ]]> - + - + Executing render actions Use the on-render element to execute one or more actions before view rendering. @@ -143,7 +147,7 @@ ]]> - + Binding to a model Use the model attribute to declare a model object the view binds to. @@ -156,7 +160,7 @@ ]]> - + The model may be an object in any accessible scope, such as flowScope or viewScope. Specifying a model triggers the following behavior when a view event occurs: @@ -169,40 +173,40 @@ If model binding fails, the view is re-rendered to allow the user to revise their edits. - + Performing type conversion When request parameters are used to populate the model (commonly referred to as data binding), type conversion is required to parse String-based request parameter values before setting target model properties. Default type conversion is available for many common Java types such as numbers, primitives, enums, and Dates. Users also have the ability to register their own type conversion logic for user-defined types, and to override the default Converters. - + Type Conversion Options - Starting with version 2.1 Spring Web Flow uses the type conversion and formatting system introduced in Spring 3 for nearly all type conversion needs. - Previously Web Flow applications used a type conversion mechanism that was different from the one in Spring MVC, which relied on the java.beans.PropertyEditor abstraction. + Starting with version 2.1 Spring Web Flow uses the type conversion and formatting system introduced in Spring 3 for nearly all type conversion needs. + Previously Web Flow applications used a type conversion mechanism that was different from the one in Spring MVC, which relied on the java.beans.PropertyEditor abstraction. Spring 3 offers a modern type conversion alternative to PropertyEditors that was actually influenced by Web Flow's own type conversion system. Hence Web Flow users should find it natural to work with the new Spring 3 type conversion. - Another obvious and very important benefit of this change is that a single type conversion mechanism can now be used across Spring MVC And Spring Web Flow. + Another obvious and very important benefit of this change is that a single type conversion mechanism can now be used across Spring MVC And Spring Web Flow. - + Upgrading to Spring 3 Type Conversion And Formatting What does this practically mean for existing applications? Existing applications are likely registering their own converters of type org.springframework.binding.convert.converters.Converter through a sub-class of DefaultConversionService available in Spring Binding. Those converters can continue to be registered as before. - They will be adapted as Spring 3 GenericConverter types and registered with a Spring 3 org.springframework.core.convert.ConversionService instance. + They will be adapted as Spring 3 GenericConverter types and registered with a Spring 3 org.springframework.core.convert.ConversionService instance. In other words existing converters will be invoked through Spring's type conversion service. The only exception to this rule are named converters, which can be referenced from a binding element in a view-state: @@ -217,7 +221,7 @@ public class ApplicationConversionService extends DefaultConversionService { Therefore such converters will not be adapted and will continue to work as before, i.e. will not involve the Spring 3 type conversion. However, this mechanism is deprecated and applications are encouraged to favor Spring 3 type conversion and formatting features. - + Also note that the existing Spring Binding DefaultConversionService no longer registers any default converters. Instead Web Flow now relies on the default type converters and formatters in Spring 3. @@ -226,7 +230,7 @@ public class ApplicationConversionService extends DefaultConversionService { Although existing applications will work without any changes, we encourage moving towards unifying the type conversion needs of Spring MVC and Spring Web Flow parts of applications. - + Configuring Type Conversion and Formatting In Spring MVC an instance of a FormattingConversionService is created automatically through the custom MVC namespace: @@ -236,9 +240,9 @@ public class ApplicationConversionService extends DefaultConversionService { xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" - http://www.springframework.org/schema/mvc + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd - http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> @@ -272,8 +276,8 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio protected void installFormatters(FormatterRegistry registry) { // ... } - -} + +} ]]> Configure it for use in Spring MVC: @@ -283,14 +287,14 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" - http://www.springframework.org/schema/mvc + http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd - http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - - - + ]]> Connection the Web Flow DefaultConversionService to the same "applicationConversionService" bean used in Spring MVC: - + - + ]]> @@ -316,20 +320,20 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio Register existing Spring Binding Converter types through the "defaultConversionService". - + Working With Spring 3 Type Conversion And Formatting An important concept to understand is the difference between type converters and formatters. - + Type converters in Spring 3, provided in org.springframework.core, are for general-purpose type conversion between any two object types. In addition to the most simple Converter type, two other interfaces are ConverterFactory and GenericConverter. - + Formatters in Spring 3, provided in org.springframework.context, have the more specialized purpose of representing Objects as Strings. The Formatter interface extends the Printer and Parser interfaces for converting an Object to a String and turning a String into an Object. - + Web developers will find the Formatter interface most relevant because it fits the needs of web applications for type conversion. @@ -339,30 +343,30 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio - + Formatting Annotations One of the best features of the new type conversion is the ability to use annotations for a better control over formatting in a concise manner. Annotations can be placed on model attributes and on arguments of @Controller methods that are mapped to requests. Out of the box Spring provides two annotations NumberFormat and DateTimeFormat but you can create your own and have them registered along with the associated formatting logic. - You can see examples of the DateTimeFormat annotation in the Spring Travel and in the Petcare along with other samples in the Spring Samples repository. + You can see examples of the DateTimeFormat annotation in the Spring Travel and in the Petcare along with other samples in the Spring Samples repository. - + Working With Dates - The DateTimeFormat annotation implies use of Joda Time. + The DateTimeFormat annotation implies use of Joda Time. If that is present on the classpath the use of this annotation is enabled automatically. By default neither Spring MVC nor Web Flow register any other date formatters or converters. Therefore it is important for applications to register a custom formatter to specify the default way for printing and parsing dates. The DateTimeFormat annotation on the other hand provides more fine-grained control where it is necessary to deviate from the default. - - For more information on working with Spring 3 type conversion and formatting please refer to the relevant sections of the Spring documentation. + + For more information on working with Spring 3 type conversion and formatting please refer to the relevant sections of the Spring documentation. - + Suppressing binding Use the bind attribute to suppress model binding and validation for particular view events. @@ -374,8 +378,8 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio ]]> - - + + Specifying bindings explicitly Use the binder element to configure the exact set of model bindings usable by the view. @@ -400,13 +404,13 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio Each binding may also apply a converter to format the model property value for display in a custom manner. - If no converter is specified, the default converter for the model property's type will be used. + If no converter is specified, the default converter for the model property's type will be used. - + @@ -418,7 +422,7 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio ]]> - In the example above, the shortDate converter is bound to the + In the example above, the shortDate converter is bound to the checkinDate and checkoutDate properties. Custom converters may be registered with the application's ConversionService. @@ -445,19 +449,19 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio If one or more blank input values are bound, validation errors will be generated and the view will re-render with those errors. - + Validating a model Model validation is driven by constraints specified against a model object. - Web Flow supports enforcing such constraints programatically as well as + Web Flow supports enforcing such constraints programatically as well as declaratively with JSR-303 Bean Validation annotations. - + JSR-303 Bean Validation - Web Flow provides built-in support for the JSR-303 Bean Validation API - building on equivalent support available in Spring MVC. - To enable JSR-303 validation configure the flow-builder-services with + Web Flow provides built-in support for the JSR-303 Bean Validation API + building on equivalent support available in Spring MVC. + To enable JSR-303 validation configure the flow-builder-services with Spring MVC's LocalValidatorFactoryBean: @@ -470,17 +474,17 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio With the above in place, the configured validator will be applied to - all model attributes after data binding. + all model attributes after data binding. - + - Note that JSR-303 bean validation and validation by convention + Note that JSR-303 bean validation and validation by convention (explained in the next section) are not mutually exclusive. - In other words Web Flow will apply all available validation + In other words Web Flow will apply all available validation mechanisms. - + Partial Validation JSR-303 Bean Validation supports partial validation via groups. For example: @@ -519,7 +523,7 @@ private String name; - + Programmatic validation There are two ways to perform model validation programatically. @@ -527,7 +531,7 @@ private String name; The second is to implement an external Validator. Both ways provide you with a ValidationContext to record error messages and access information about the current user. - + Implementing a model validate method Defining validation logic in your model object is the simplest way to validate its state. @@ -540,7 +544,7 @@ public class Booking { private Date checkinDate; private Date checkoutDate; ... - + public void validateEnterBookingDetails(ValidationContext context) { MessageContext messages = context.getMessageContext(); if (checkinDate.before(today())) { @@ -566,11 +570,11 @@ public class Booking { - Any number of validation methods are defined. Generally, a flow edits a model over a series of views. In that case, a validate method would be defined + Any number of validation methods are defined. Generally, a flow edits a model over a series of views. In that case, a validate method would be defined for each view-state where validation needs to run. - + Implementing a Validator The second way is to define a separate object, called a Validator, which validates your model object. @@ -607,7 +611,7 @@ public class BookingValidator { Then, anytime the booking model needs to be validated, this bookingValidator instance would be invoked for you. - + Default validate method A Validator class can also define a method called validate not associated (by convention) with any specific view-state. @@ -617,7 +621,7 @@ public class BookingValidator { public class BookingValidator { public void validate(Booking booking, ValidationContext context) { //... - } + } }]]> @@ -636,12 +640,12 @@ public class BookingValidator { }]]> - In above code sample the method validateEnterBookingDetails will be called first. + In above code sample the method validateEnterBookingDetails will be called first. The default validate method will be called next. - + ValidationContext A ValidationContext allows you to obtain a MessageContext to record messages during validation. @@ -649,9 +653,9 @@ public class BookingValidator { This information can be used to customize validation logic based on what button or link was activated in the UI, or who is authenticated. See the API Javadocs for ValidationContext for more information. - + - + Suppressing validation Use the validate attribute to suppress model validation for particular view events: @@ -666,7 +670,7 @@ public class BookingValidator { In this example, data binding will still occur on back but validation will be suppressed. - + Executing view transitions Define one or more transition elements to handle user events that may occur on the view. @@ -677,7 +681,7 @@ public class BookingValidator { Implementing view transitions is illustrated in the following sections. - + Transition actions A view-state transition can execute one or more actions before executing. @@ -712,10 +716,10 @@ public class BookingAction { When there is more than one action defined on a transition, if one returns an error result the remaining actions in the set will not be executed. If you need to ensure one transition action's result cannot impact the execution of another, define a single transition action that invokes a method that encapsulates all the action logic. - + - + Global transitions Use the flow's global-transitions element to create transitions that apply across all views. @@ -727,8 +731,8 @@ public class BookingAction { ]]> - - + + Event handlers From a view-state, transitions without targets can also be defined. Such transitions are called "event handlers": @@ -743,7 +747,7 @@ public class BookingAction { They simply execute their actions and re-render the current view or one or more fragments of the current view. - + Rendering fragments Use the render element within a transition to request partial re-rendering of the current view after handling the event: @@ -751,7 +755,7 @@ public class BookingAction { - + ]]> @@ -763,7 +767,7 @@ public class BookingAction { - + Working with messages Spring Web Flow's MessageContext is an API for recording messages during the course of flow executions. @@ -772,7 +776,7 @@ public class BookingAction { Three distinct message severities are provided: info, warning, and error. In addition, a convenient MessageBuilder exists for fluently constructing messages. - + Adding plain text messages - + Adding internationalized messages - + Using message bundles Internationalized messages are defined in message bundles accessed by a Spring MessageSource. @@ -816,7 +820,7 @@ reservationConfirmation=We have processed your reservation - thank you and enjoy ]]> - + Understanding system generated messages There are several places where Web Flow itself will generate messages to display to the user. @@ -851,7 +855,7 @@ typeMismatch=The {0} field is of the wrong type. - + Displaying popups Use the popup attribute to render a view in a modal popup dialog: @@ -864,13 +868,13 @@ typeMismatch=The {0} field is of the wrong type. Web Flow will send a response to the client requesting a redirect to the view from a popup, and the client will honor the request. - + View backtracking By default, when you exit a view state and transition to a new view state, you can go back to the previous state using the browser back button. These view state history policies are configurable on a per-transition basis by using the history attribute. - + Discarding history Set the history attribute to discard to prevent backtracking to a view: @@ -879,7 +883,7 @@ typeMismatch=The {0} field is of the wrong type. ]]> - + Invalidating history Set the history attribute to invalidate to prevent backtracking to a view as well all previously displayed views: @@ -888,5 +892,5 @@ typeMismatch=The {0} field is of the wrong type. ]]> - + diff --git a/src/reference/whatsnew.xml b/src/reference/whatsnew.xml index a2544779..1e689ee3 100644 --- a/src/reference/whatsnew.xml +++ b/src/reference/whatsnew.xml @@ -1,20 +1,24 @@ - + What's New - + Spring Web Flow 2.4 - + Minimum JSF 2.0 Requirement - Java ServerFaces version 1.2 and earlier are no longer supported by Spring Web Flow, if you have not done so already you will need to upgrade to JSF 2.0 or above. + Java ServerFaces version 1.2 and earlier are no longer supported by Spring Web Flow, if you have not done so already you will need to upgrade to JSF 2.0 or above. In addition the Spring Faces components that were previously provided with JSF 1.2 for progressive AJAX enhancements have been removed in this release. See . - + Portlet API 2.0 and JSF 2.0 support The internal Portlet integration introduced in Spring Web Flow 2.2 has been upgraded for JSF 2.0 compatibility. @@ -23,13 +27,13 @@ included as part of their Spring configuration. See . - + Saving Flow Output to Spring MVC Flash Scope Flow output can now be saved to Spring MVC Flash Scope for any end-state that issues an internal redirect. To enable this feature set FlowHandlerAdapter.saveOutputToFlashScopeOnRedirect. See . - + Partial JSR-303 Bean Validation Partial validation with JSR-303 Bean Validation groups is now supported through the validation-hints @@ -37,48 +41,48 @@ - + Spring Web Flow 2.3 - + Embedding A Flow On A Page By default Web Flow does a client-side redirect upon entering every view state. - That makes it impossible to embed a flow on a page or within a modal dialog and execute more than one view state without causing a full-page refresh. + That makes it impossible to embed a flow on a page or within a modal dialog and execute more than one view state without causing a full-page refresh. Web Flow now supports launching a flow in "embedded" mode. In this mode a flow can transition to other view states without a client-side redirect during Ajax requests. See and . - + Support For JSR-303 Bean Validation Support for the JSR-303 Bean Validation API is now available building on equivalent support available in Spring MVC. - See for more details. + See for more details. - + Flow-Managed Persistence Context Propagation Starting with Web Flow 2.3 a flow managed PersistenceContext is automatically extended (propagated) to sub-flows assuming the subflow also has the feature enabled as well. See . - + Portlet 2.0 Resource Requests Support for Portlet 2.0 resource requests has now been added enabling Ajax requests with partial rendering. URLs for such requests can be prepared with the <portlet:resourceURL> tag in JSP pages. Server-side processing is similar to a combined an action and a render requests but combined in a single request. - Unlike a render request, the response from a resource request includes content from the target portlet only. + Unlike a render request, the response from a resource request includes content from the target portlet only. - + Custom ConversationManager - The <flow-execution-repository> element now provides a conversation-manager attribute accepting a reference to a ConversationManager instance. + The <flow-execution-repository> element now provides a conversation-manager attribute accepting a reference to a ConversationManager instance. - + Redirect In Same State By default Web Flow does a client-side redirect when remaining in the same view state as long as the current request is not an Ajax request. @@ -89,7 +93,7 @@ See . - + Samples The process for building the samples included with the distribution has been simplified. @@ -117,26 +121,26 @@ mvn package - + Spring Web Flow 2.2 - + JSF 2 Support Comprehensive JSF 2 Support - Building on 2.1, Spring Web Flow version 2.2 adds support for core JSF 2 features - The following features that were not supported in 2.1 are now available: - partial state saving, JSF 2 resource request, handling, and JSF 2 Ajax requests. - At this point support for JSF 2 is considered - comprehensive although not covering every JSF 2 feature -- + Building on 2.1, Spring Web Flow version 2.2 adds support for core JSF 2 features + The following features that were not supported in 2.1 are now available: + partial state saving, JSF 2 resource request, handling, and JSF 2 Ajax requests. + At this point support for JSF 2 is considered + comprehensive although not covering every JSF 2 feature -- excluded are mostly features that overlap with the core value Web Flow provides - such as those relating to navigation and state management. + such as those relating to navigation and state management. See for important configuration changes. Note that partial state saving is only supported with Sun Mojarra 2.0.3 or later. It is not yet supported with Apache MyFaces. This is due to the - fact MyFaces was not as easy to customize with regards to how component state is stored. + fact MyFaces was not as easy to customize with regards to how component state is stored. We will work with Apache MyFaces to provide this support. In the mean time you will need to use the javax.faces.PARTIAL_STATE_SAVING context parameter in web.xml to disable partial state saving with Apache MyFaces. @@ -145,42 +149,42 @@ mvn package Travel Sample With the PrimeFaces Components - The main Spring Travel sample demonstrating Spring Web Flow and JSF support + The main Spring Travel sample demonstrating Spring Web Flow and JSF support is now built on JSF 2 and components from the PrimeFaces component library. Please check out the booking-faces sample in the distribution. - Additional samples can be found at the Spring Web Flow - Prime Faces - - Showcase, an SVN repository within the - spring-samples + Additional samples can be found at the Spring Web Flow - Prime Faces + + Showcase, an SVN repository within the + spring-samples repository. Use these commands to check out and build: - + ]]> + - + Spring Security Facelets Tag Library A new Spring Security tag library is available for use with with JSF 2.0 or with JSF 1.2 Facelets views. - It provides an <authorize> tag as well as several EL functions. - See for more details. + It provides an <authorize> tag as well as several EL functions. + See for more details. - + Spring JavaScript Updates Deprecated ResourcesServlet Starting with Spring 3.0.4, the Spring Framework includes - a replacement for the ResourcesServlet. Please see + a replacement for the ResourcesServlet. Please see the Spring Framework documentation for details on the custom mvc namespace, - specifically the new - "resources" + specifically the new + "resources" element. @@ -192,28 +196,28 @@ mvn package Note that applications are generally encouraged to prepare their own custom Dojo build for optimized performance depending on what parts of Dojo are - commonly used together. For examples see the - scripts + commonly used together. For examples see the + scripts used by Spring Web Flow to prepare its own custom Dojo build. Two Spring JS artifacts - The spring-js artifact has been split in two -- the new artifact + The spring-js artifact has been split in two -- the new artifact (spring-js-resources) contains client side resource (.js, .css, etc.) while the existing artifact (spring-js) contains server-side Java code only. Applications preparing their own custom Dojo build have an option now to - avoid including spring-js-resources and put Spring.js and + avoid including spring-js-resources and put Spring.js and Spring-Dojo.js directly under the root of their web application. Client resources moved into META-INF/web-resources - Bundled client resources (.js, .css, etc.) + Bundled client resources (.js, .css, etc.) have been moved to META-INF/web-resources from their previous location under META-INF. This change is transparent for applications but will result in simpler and safer configuration when using the new resource handling @@ -221,17 +225,17 @@ mvn package - + JSF Portlet Support Portlet API 2.0 and JSF 1.2 support - In previous versions of Spring Web Flow support for JSF Portlets relied on - a Portlet Bridge for JSF implementation and was considered experimental. - Spring Web Flow 2.2 adds support for JSF Portlets based on its own internal + In previous versions of Spring Web Flow support for JSF Portlets relied on + a Portlet Bridge for JSF implementation and was considered experimental. + Spring Web Flow 2.2 adds support for JSF Portlets based on its own internal Portlet integration targeting Portlet API 2.0 and JSF 1.2 environments. See for more details. - The Spring Web Flow Travel JSF Portlets sample has been successfully + The Spring Web Flow Travel JSF Portlets sample has been successfully tested on the Apache Pluto portal container.
Flow Packaging