From e11805f0615dbda5bea28e73bbf8dda9b6b29a8c Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Tue, 4 Nov 2008 13:02:54 +0000 Subject: [PATCH] a bit more about exception handling --- spring-webflow-reference/src/actions.xml | 109 ++++++++++++++++-- .../src/spring-webflow-reference.xml | 2 +- 2 files changed, 98 insertions(+), 13 deletions(-) diff --git a/spring-webflow-reference/src/actions.xml b/spring-webflow-reference/src/actions.xml index 81c57515..27e761a3 100644 --- a/spring-webflow-reference/src/actions.xml +++ b/spring-webflow-reference/src/actions.xml @@ -19,8 +19,7 @@ - -]]> +]]> The full example below illustrates a interview flow that uses the action-state above to determine if more answers are needed to complete the interview: @@ -64,8 +63,7 @@ - -]]> +]]> @@ -88,6 +86,10 @@ + + java.lang.String + the String value + java.lang.Boolean yes (for true), no (for false) @@ -96,10 +98,6 @@ java.lang.Enum the Enum name - - java.lang.String - the String value - any other type success @@ -112,15 +110,102 @@ - + - -]]> +]]> + + Action implementations + + While writing action code as POJO logic is the most common, there are several other action implementation options. + Sometimes you need to write action code that needs access to the flow context. + You can always invoke a POJO and pass it the flowRequestContext as an EL variable. + Alternatively, you may implement the Action interface or extend from the MultiAction base class. + These options provide stronger type safety when you have a natural coupling between your action code and Spring Web Flow APIs. + Examples of each of these approaches are shown below. + + + Invoking a POJO action + ]]> + + + + + + Invoking a custom Action implementation + ]]> + + + + + + Invoking a MultiAction implementation + +]]> + + + + + + + Action exceptions + + Actions often invoke services that encapsulate complex business logic. + These services may throw business exceptions that the action code should handle. + + + Handling a business exception with a POJO action + + The following example invokes an action that catches a business exception, adds a error message to the context, and returns a result event identifier. + The result is treated as a flow event which the calling flow can then respond to. + + ]]> + + + + + - Action execution examples + Other Action execution examples on-start diff --git a/spring-webflow-reference/src/spring-webflow-reference.xml b/spring-webflow-reference/src/spring-webflow-reference.xml index a5baaae8..09f083ad 100644 --- a/spring-webflow-reference/src/spring-webflow-reference.xml +++ b/spring-webflow-reference/src/spring-webflow-reference.xml @@ -25,7 +25,7 @@ Spring Web Flow Reference Guide Spring Web Flow Version 2.0.4 - October 2008 + November 2008 Keith