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

左心房为你撑大大i 提交于 2019-12-03 04:57:49

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.

sujeeshValath

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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!