Expert Spring MVC and Web Flow

(Dana P.) #1

State Scoped ExceptionHandlers


You may decide that you want exception handling to be implemented at a finer-grained level
than that of a flow. You can also define ExceptionHandlers at the state level against any state
type (action, decision, and so on). To achieve this, simply move the exception-handlerdecla-
ration to within the definition of the state. Listing 12-30 demonstrates how to scope the
ExceptionHandler.


Listing 12-30.Spring Web Flow Fragment Registering a State-Level ExceptionHandler







Exception Handling Summary


Exception handling within Spring Web Flow is simple yet powerful. Any number of
state ExceptionHandlers can be registered at both the flow and state level. The default
ExceptionHandlerimplementation is sufficient for most scenarios, allowing you to catch
an exception and execute a recovery transition as part of the flow definition. Providing your
own implementation is also possible by implementing a custom state ExceptionHandler.


Summary


Spring Web Flow is a powerful framework for defining and executing reusable, self-contained
controller modules within a web application. However, no tool can cater for every possible
use case. We’ve shown you that Spring Web Flow provides a number of extension points and
implementations of key strategies that allow for customization. We’ve also shown how Spring
Web Flow drives the execution of your business logic without tying you to Web Flow APIs.
Finally, we’ve demonstrated how Spring Web Flow employs the concept of a continuation to
solve many issues facing web application developers.


CHAPTER 12 ■ADVANCED SPRING WEB FLOW 369
Free download pdf