Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Spring Web Flow 2: A boon to JSF developers

JSF 2.0 features elevate SWF 2 to more than a page-flow engine

  • Print
  • Feedback

Spring Web Flow 2 supports JavaServer Faces technology through the new Spring Faces module. Spring Faces lets you use JSF as a view technology in Web applications, with the Spring MVC Web framework underneath. Not only does Spring Web Flow 2 address a few thorny JSF programming issues, but it also it gives you advanced features available only in the JSF 2.0 specification. JavaWorld contributor Xinyu Liu presents an overview of Spring Web Flow 2 and details its benefits for JSF developers.

JavaServer Faces, part of the Java EE 5 specification, is a component-oriented and event-driven Web development technology. The JSF developer community has made ample use of its pluggable architecture to enrich the technology by creating and integrating various pieces -- mostly rich UI components, or widgets -- into the JSF backbone. The Spring framework team, meanwhile, has taken an inverse approach. Spring Web Flow 2 makes the JSF UI component model fit into the Spring MVC framework, so that it can benefit from the Spring MVC infrastructure and Web flow navigation. Spring Web Flow 2 aims to make Web development in JSF and Spring MVC easier, with less coding, less coupling, more flexibility, and Ajax techniques that enhance the user experience.

Web page navigation in JSF is specified by default with the <navigation-rule> tag in a faces-config.xml file. In Struts-like fashion, the simple navigation rules map a logical view name to a JavaServer Pages (JSP) page's path. The logical view name is, in general, determined and returned by a JSF backing bean's action method. This approach decouples backing-bean classes from the physical paths to JSP pages, but it still spreads page-navigation logic across Java programs and XML configurations.

Spring Web Flow is fundamentally a workflow engine designed to manage page navigation outside of Java programs. The Spring Web Flow 2 release offers substantial enhancements over its predecessor, however. In particular, the newly introduced Spring Faces module improves Spring's support for JSF. This module allows you to use JSF as a view technology in Web applications on top of Spring MVC. Spring Web Flow 2 addresses some debatable programming issues in JSF, and it supports great features, including some that are available only in the JSF 2.0 (JSR 314) specification, such as:

  • A unified abstract JavaScript library (Spring-JS) for Ajax-enhanced user interfaces and rich validation behavior
  • Facelets integration
  • Support for the JSF Portlet Bridge
  • Both client-side and domain-model validation
  • Theme-controlled look and feel

Spring Web Flow 2 seems tailored exclusively for JSF developers, in that it makes programming with JSF even simpler and smoother than programming with the Spring MVC front end. Read on to learn about Spring Web Flow 2's features and the many compelling reasons to use it for JSF applications.

A workflow engine

Spring Web Flow is a workflow engine designed exclusively for Web page navigation. A Web flow consists of a set of states (view states or action states) and the transitions between the states. Like jPDL in JBoss jBPM, the XML-formatted flow definition language (FDL) in Spring Web Flow is a domain-specific language (DSL) that lets you express Web flows in a declarative or graph-oriented manner (with IDE support). At least theoretically, business people and developers can use the diagrams -- the visual Web flows -- to collaborate on application design. From the perspective of Unified Modeling Language (UML), the visual flows model activity diagrams effectively.

  • Print
  • Feedback

Resources

More