4

So I'm using Spring Web Flow on a project and want to make use of the history="discard" and history="invalidate" attributes on elements.

I have placed those attributes where I want them, however, when I try to test whether or not they work by navigating to a view after the history attribute is run on the transition, it directs me to an exception page.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key 'e1s1'

So sure, it's saying I deleted that state from the history so it can't find it. I don't really see why there isn't some built in mechanism to handle this in the first place, but that aside, I haven't been able to figure out a way to gracefully handle this exception so that I can just redirect them to an error page or would be nicer to just send them back to where they came from.

<view-state id="page1">
    <transition on="gotoNextPage" to="page2" history="invalidate" />
</view-state>
<view-state id="page2"/>

How is this behavior supposed to be achieved, so that pressing the back button on page2 does not create an exception but just leaves you at page 2?

alexbt
  • 16,415
  • 6
  • 78
  • 87
Rich
  • 2,805
  • 8
  • 42
  • 53
  • 1
    Considering the lack of views and response, apparently Spring Web Flow is a non-production ready framework with a pitiful user base. Thanks for looking into that, team lead, before we signed onto the contract and locked ourselves into it. – Rich Sep 30 '11 at 15:25
  • I sympathize with your frustration. We also decided to use SWF because it handles the bulk of our cases so well. But there are other things that seem very common that it just doesn't do at all. And like you, I wonder where the user base is with both here and the forums getting very few responses. – dbreaux Mar 14 '12 at 19:59

1 Answers1

2

I did a lot of searching on this.

This old forum post has 2 solutions (with sample code).

The first is to catch the exception and display a page that use javascript to forward() back to the original page - in effect undoing the back.

The 2nd solution examines the flow state and sends them to most recent valid flow snapshot.

I'm as perplexed as you are that there is no out of box solution. Everyone must encounter this issue. There is a JIRA issue filed for those interested in following the progress.

Patrick
  • 3,901
  • 1
  • 25
  • 30
  • Not the solution I ended up using, but will accept since mine is mostly proprietary to my company's application. I ended up extending FlowExecutionListenerAdapter and handling the exception directly to try going forward an execution step once (using a query param to prevent infinite recursion if the ++ case fails with same exception) and then just send the user to the landing/login page – Rich Nov 14 '12 at 18:01