views:

111

answers:

3

Spring MVC has become a very popular framework for building enterprise web applications. Any complex web application has certain flows that need to be coded, including some conditional flows (i.e., show order processed if the credit card information was correct, or validation errors if something was not entered correctly).

When does it make sense to use Spring WebFlow on top of Spring MVC? What should be the decision making process regarding using Spring WebFlow?

+3  A: 

If you have a web application that has some application process. For example, if you have some kind of sign up process that one button can go to one page while another can go to a different page. Spring Webflow can handle transitioning to different sets of processes very well.

Basically, if some part of your application is linked and pages depend on each other during the course of an execution SWF is good to use.

John V.
A: 

One problem that webflow solves efficiently is it cleanly separates (or at least it makes very hard to mix) business logic from your control logic.
Agree with @John on the use cases but I would like to point out that once you start using webflow heavily, you will find yourself writing a lot of xml files (since in webflow you specify all the flows in xml files). This is almost a deal breaker for me personally.

Sasi
@Sasi I agree the xml is very cumbersome but the alternative is even much more so (writing your own flow logic with java). Ive seen people try to do it before webflow was available and it is a nightmare to maintain.
John V.
A: 

What I personally like in webflow most are 2 things:

  1. Ability to inherit flows and view-states. This is quite handy when you have some common logic aspects that you want to share between different parts of your application. For example, you have CRUD logic that you want to abstract in separate flow and then allow child flows to inherit this logic. Each flow can have input and output, so your logic can be very fine-grained.
  2. Powerful testing framework. It is possible to cover almost all aspects of your flow logic in unit tests. You can emulate many things programmatic, such as action firings, transitions from one view to another, flow persistence handling and and so on

What I don't like is inconsistency and poor backward compatibility of newer versions. For example, latest webflow 2.1 is not compatible with JSF 1.x jira. There are also numerous problems with integrating with Spring Security. For example, in spring security 3.x they just changed some package names In general, as Sasi mentioned, webflow will almost force you separate your logic in different webflows - and this is nice I think.

denis_k