开发者

When does it make sense to use Spring WebFlow on top of Spring MVC?

Spring MVC has become a very popular framework for b开发者_开发百科uilding 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?


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.


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.


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.


I have used MVC and SWF. Personally I prefer SWF over MVC due to the following two solid reasons:

  1. Spring MVC has no built in mechanism for session control across multiple tabs in same browser.
  2. Handling browser go backs is easier in SWF than MVC.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜