3
votes

I am building a a web app with Spring MVC and hibernate. I am struggling with scope. E.g., create parent and children on same interface requires resetting child bean after first child created. Spring MVC does not allow removal of bean from session scope. At the same time, shifting children across multiple request scopes is not practical. I need a conversation scope.

I am now looking at Spring Web Flow as a solution. However, it is poorly documented and seems to depend entirely on xml configuration. Both these features seem to suggest it is an older and perhaps not well supported project.

Can anyone advise on whether I should invest time learning Spring Web Flow, or perhaps suggest alternative solutions that tie into Spring MVC.

3
Ehrm last release is from a couple of weeks ago and i doubt you are reading the correct documentation as support for java based configuration has been there for a while... See docs.spring.io/spring-webflow/docs/2.4.0.RELEASE/reference/html/… - M. Deinum
@M.Deinum may have mistaken your question for JavaConfig. He's right, of course. JavaConfig support was added a while back. But I believe you're asking about how the web flows themselves are defined. That's still 100% XML. - Stephen Harrison

3 Answers

7
votes

I've spent some time on this now.

I think the reason for xml as opposed to annotation is design. Once one has one's head around it, the flow config is simple and leads to very fast development.

Yes, it seems to be in maintenance mode, but the design is solid and reliable and development seems to be very efficient. Learning curve is a little steep, especially if integrating into an extant webapp, but I was up and running in about three days.

Webflow's own documentation is not great, but the tutorial linked here is excellent.

UPDATE

5 months on and I have built a complete assessment system (i.e test/exam system). My background is in IT and I have a Ph.d in psychology.

The system I built has been thoroughly tested and stress tested.

Advantages of webflow.

  1. A person can start a test, give up and restart in the same session with no problems since flowState takes care of everything
  2. There is full control of when the user can use the back button and how far back the user can go. Returning to state after an illegitimate backbutton usage is easy and user friendly.
  3. Stress test performance is excellent
  4. Configuration is easy. I spent almost no time dealing with design or bug issues related to Webflow.
  5. FRom a higher level design perspective, there were no use cases that were required from a business perspective that could not be implemented.

Disadvantages

Since all objects are serialized before presentation on the webpage, you have to be very careful about how you cache objects if you take them out of the flowState beans.

5
votes

Spring Web Flow appears to be maintained, but not in active development. I see a handful of commits, mostly updating dependency versions and fixing bugs.

You are correct that the configuration of the flow is XML-only, which I believe is the single biggest drawback of this aging Spring project. I have searched for a DSL or dynamic builders and I did not find anything.

Having said that, I'd give it a shot. Simple flows—even dynamic and inherited flows—are possible. In addition, the backing form and the POST-Redirect-GET Pattern implementations may be useful to you. That last technique prevents form resubmission when you use the browser back button.

1
votes

I have been looking at webflow myself (for the past day, ~16 hours) since after I seen "primefaces".

Webflow offers varying types of states and transitions to those states. States can have a view associated with it (HTML page or JSP page -> primefaces comes in here). Each JSP pages are templates, like PHP just using java and xhtml. Using primefaces components the interaction between the client and server "seems" almost automated (a plus for quick development). Webflow also offers flow variables, which is a java data object. The flow variable can have the life over the flow and is used by views and templates. Webflow allows you to control transitions between all states.

However, I think this is where I stop my research. First, what is the advantage of webflow over a good client side web application using AngularJS with Spring MVC (@RequestMapping), if flow control is needed build it on the client. If you would like a variable that exists over the lifetime of the session, make a javascript variable, however if the variable needs to only exist on the server and you would like to use templates, then webflow seems like a ideal choice.

If you need a state-ful webapp then it might be a good idea to checkout Spring HATEOAS type concept (passing the state as a parameter to the client), and that parameter refers to limited time availability variables. Less coding and seems to conform to internet model better.