Spring Web Flow
Spring WebFlow is a subproject of Spring Framework which provides you appropriate infrastructure components necessary to build rich web applications.
Spring WebFlow is a framework in itself for implementation stateful flows in your web application. It plugs into Spring MVC based application as a controller with ease making the right choice for navigation in your Spring MVC application. Spring WebFlow supports a variety of view technologies in which JSP and JSF view technology is natively supported, again making it right choice for web applications using these view technologies.
Spring WebFlow gives you capability to specify your web applications navigation rules, manage conversational state and also gives you ways by which to modularize and reuse your application code.
In this section we will go to some detail of Spring WebFlow and will also give details on how to integrate it with your Spring MVC based web application. The first few sections give you the main features, benefits and advantages of Spring WebFlow and slowly get you through the nitty-gritties of this wonderful framework.
Before going into the detail of Spring Web Flow, its features, advantages, benefits and above all its architecture, it is important to know its history.
In the year 2004 Erwin Vervaet developed Spring Web Flow project as a simple extension to the Spring MVC framework for providing infrastructural capabilities like navigational rule configuration and conversational state maintenance.
In the year 2005 Keith Donald introduced Spring Web Flow into the Spring portfolio and later on grew it into a full-fledged sub-project of the Spring Framework.
The 1.0 version of Spring Web Flow was release in the year 2006 and 2.0 version in the year 2008. The version 2.0 saw a major re-organization of Spring Web Flow and had a good integration with the native support for famous JavaServer Faces view technology. The current version at the time of writing this book is 2.3.1.
Benefits and Advantages
Spring Web Flow gives a number of benefits/advantages which best describe why it is still in business. These can be summarized in bullet points as shown below:
- It captures web applications page or UI flow in a clear and readable way and with the use of SpringSouce Tool Suite can show these flow in a pictorial fashion.
- Provides a consistent way of perfecting and navigating flows of your web application.
- Makes sure that your web application works fine in all aspects when the user plays with the browsers back, forward and above all the refresh button. These buttons being usable for users can create big problems from the developer’s point of view to handle these in correct way.
- Modularization and reuse is one of the key benefits of using Spring Web Flow.
- Capability of managing sophisticated conversational state management is a very key benefit of Spring Web Flow.
- Works well with all the powerful features of Spring Framework and leverages it to the maximum extend possible.
Spring Web Flow Architecture
Spring Web Flow by itself is not able to create a complete web application in all aspects. Spring Web Flow is at its best when it is used in conjunction with traditional web controllers in a web environment. Working well with controllers in web environment makes it ideal to be integrated with MVC based web application frameworks like Spring MVC, Struts, JSF etc. In that case Spring Web Flow works well and compliments these web application frameworks.
Marrying Spring Web Flow with any MVC based web application framework can be considered as marriage made in heaven in all aspects. Figure 14-12 below shows the interaction or rather working of Spring Web Flow with traditional controller based frameworks in a pictorial fashion.
Figure 14-12. Spring Web Flow with any standard FrontController based frameworks
The working of Figure 14-1 can be summarized as shown below:
- Step 1 – client requests hit the Front Controller servlet. This servlet changes according to the MVC framework being integrated with.
- Step 2 – according to the mapping specified in the configuration, the request is routed to either normal controllers or a flow controller
- Step 3 – the controller returns the control now to the Front Controller with updated model and appropriate view to be rendered. The Font Controller uses the model, resolves the view and renders it.
It’s important to understand the various terminologies used in conjunction with Spring Web Flow. This section covers common spring Web Flow terminologies in some detail.
Page Visitors: 6744