This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

comparing with Spring Web MVC

Apr 20th, 2005, 12:57 PM

Hi,

when comparing Spring Web MVC with Spring Webflow MVC for working with Model and Forms,
in Spring MVC i used extended SimpleForm or MultiActionController, with WebFlow i have to use extended FormAction.
Now in WebFlow i have a AbstractAction for adding Actions which where do something that is not model based. in Spring MVC the controllers have done this too.

so can i say that the Conntrollers from Spring MVC are more or less the Actions in WebFlow or the Actions in Webflow are the controllers?

but where is the benefit of WebFlow? If i have understand right, the only thing is, that the objects well be saved automaticly in a session and that i have only one url for the flow, so that a bookmark too that will always start at the beginning, with Spring MVC i can do the same but i have to save alle object states manuelly, and check if the flow have startet at the beginning, all at the controllers. is that right?

if so, how would be the future of Spring MVC? for my new project i will always use WebFlow because i of this, and because it can be better drawn (more use of externel UML Objects) and it have allready Portlet Support, or why should i use Spring MVC (resources, speed)?

You're a bit off on the general ideas. If I was calling anything a "controller" in WebFlow, it would be the flows (the xml files, if that's how you're doing it). Spring MVC, for example SimpleFormController, is like a prebuilt flow that gives you hooks in different parts of it's hard-coded processing.

SimpleFormController still has a place. Personally, I don't want to write new flows every time I just need to make a free-browsing, one-page form. For those situations, the behovior of SimpleFormController is exactly what I need. However, for anything more complicated then that, I'm hooked on WebFlow. Things that turn into an absolute nightmare with AbstractWizardFormController are a piece of cake with WebFlow. Plus, you get to use subflows, which is, I think, the most powerful feature.

Comment

I completely agree with what wiggles says: a Controller in Spring MVC is similar to an entire flow in SWF. The hook methods a controller provides (eg. doSubmitAction() in SimpleFormController) are similar to Action implementations used by a flow: they allow you to plugin custom logic.

So a typical application will mix both Spring MVC and SWF. Use simple controllers like SimpleFormController when that is all you need. When you have more complex flow requirements, use SWF.

Erwin

Comment

ok thank you, so i can say tha a controller in MVC have to tasks, flow and actions, with SWF i have a flow separatly from the actions, this is a nice thing, so you can reuse the actions in other flows.

now my first flow is running well and i think i now what you mean, but by the way SWF have support for JSR-168, MVC doesn't.