Advanced Spring Web Flow
This chapter builds on the introduction we presented in Chapter 11 and covers some of the
more advanced problems that Spring Web Flow solves. You will see how Spring Web Flow sim-
plifies web application development by elegantly solving the Back button problem, as well as
the duplicate form submission problem.
After reading this chapter you will have a deeper understanding of how Spring Web Flow
works and be able to extend the framework to meet your needs.
Business Logic and Flows
Chapter 11 introduced the Spring Web Flow framework and walked through the implementa-
tion of an example flow. It also discussed how Spring Web Flow should not be treated as a
golden hammer. One area where you need to be especially considerate of this point is that
of logic; how much and what type of logic is appropriate in a web flow definition?
Business Logic
Let’s reconsider the problem Spring Web Flow solves, that of modeling conversations and exe-
cuting complex page navigation rules. It is neither a business rules engine nor a generic work
flow engine, and it does not claim to be. Spring Web Flow fits very firmly in the presentation
layer of the layered architecture discussed in Chapters 2 and 3. Because of its power and the
fact a flow definition “feels” somewhat like a work flow document, it can be tempting to allow
business logic to creep into the flow definition, but it really doesn’t belong there.
Why does this matter? Well, primarily because your business rules are no longer isolated
or explicit. As an example, one of us was responsible for developing a web application that
allowed nontechnical users to maintain their own web site content. Part of the business rules
stated that users could only edit pages for which they had both exclusive access and appropri-
ate permissions. To meet these requirements the author produced the flow fragment shown in
Listing 12-1.
Listing 12-1.Spring Web Flow Fragment Enforcing Business Rules
CHAPTER 12
■ ■ ■