Expert Spring MVC and Web Flow

(Dana P.) #1

Not a Golden Hammer


Although Spring Web Flow is very powerful, flexible, and well architected, it is a solution to a spe-
cific problem—that of conversation scope. The definition of a conversation (for our purposes) is
a logical progression through a predetermined set of steps to complete a business goal.
Is Spring Web Flow suitable for all web applications? No. Is it suitable for sites that are
effectively static resources, each page disconnected from others where the user can jump from
one page to another? No.
It is tempting when using Spring Web Flow to start thinking of it as the only weapon in
your toolbox, the proverbial golden hammer (you only have a hammer, so everything looks
like a nail), but this would be a misuse of the tool.
There are very few absolutes in web development, however, we offer Table 11-2 simply as
a pragmatic guide.

Table 11-2.When to Use Spring Web Flow
Solution When to Use
Spring MVC Controller The page exists in isolation, not as part of a flow,
and requires very little logic to generate it.
Spring MVC SimpleFormController The page is part of a simple form-submission
flow, such as a simple search box.
Spring MVC AbstractWizardFormController A process is represented by a set of sequential
pages through which the user is guided.
Spring Web Flow Any nontrivial, stateful, guided multipage
navigation is required.

■NoteEven simple use cases may be better implemented in Spring Web Flow if they can be reused as
subflows by larger flows. We will cover this in Chapter 12.

The key point is that Spring Web Flow isn’t a replacement for Spring MVC; it is a comple-
ment to it.

The Big Picture


So what makes up Spring Web Flow? What does it look like? How does it fit into your applica-
tion architecture?

314 CHAPTER 11 ■INTRODUCTION TO SPRING WEB FLOW

Free download pdf