0

I created a Spring Webflow exception-handler for my application and defined it in my abstract parent flow. In this handler I add FacesMessages to display several errors in a generic way. Now i got the problem that i can't handle an exception that occures in an action-state. I try to go back to the last valid view-state or something like that (or maybe go to the start-state). Anyway, I don't want the application to crash or show a blank page.

@Override
public void handle(FlowExecutionException exception, RequestControlContext context) {
    Object testState = context.getCurrentState();
    if(testState instanceof ActionState){
         //what to do here?
    }
}

I am using Spring Webflow Version 2.3.0.RELEASE with JSF 2 on MyFaces.

Best regards, Patrick

4

1 回答 1

4

You can execute a transition to another state (the transition must exist). So, inside your if statement you could do the following:

TransitionDefinition errorDefinition = context.getMatchingTransition("errorState");
Transition errorTransition = (Transition)errorDefinition;
context.execute(errorTransition);

The transition could be a global transition to a generic error page.

Regards.

于 2013-03-08T12:49:09.143 回答