Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: Spring Faces best practice for error handling?

  1. #21
    Join Date
    Aug 2010
    Posts
    2

    Default How to transition to view-state

    I want to use the FlowExecutuinExceptionHandler to handle all business exceptions and only to show message on the current view. The problem is when the exception is thrown from for example an action state. How can I redirect to the last view state?

  2. #22
    Join Date
    Jul 2008
    Posts
    157

    Default

    If you know its id (You stored it in a variable somewhere), you can do this:
    Code:
    context.execute(new Transition(new DefaultTargetStateResolver(originatingViewStateId)));

  3. #23
    Join Date
    Mar 2010
    Posts
    9

    Default

    Quote Originally Posted by Bergkamp View Post
    I want to use the FlowExecutuinExceptionHandler to handle all business exceptions and only to show message on the current view. The problem is when the exception is thrown from for example an action state. How can I redirect to the last view state?
    I have the problem also. I saw the solution by triqui but dont have the originatingViewStateId. Whats a good generic way of storing this. Can anyone point to a good solution?

  4. #24
    Join Date
    Jul 2008
    Posts
    157

    Default

    Well, webflow had support for this till the 2.0.5 version. It was removed in the 2.0.6.
    The ViewState class would store "webflow.originatingViewState" in the requestScope when it was exited.

    So, you could store the id you want yourself with something like this:
    Code:
    <view-state id="someId">
        <on-entry>
            <set name="requestScope.originatingViewStateId" value="someId" />
        </on-entry>
    </view-state>
    But is not generic, as you requested.

    They are planning to add a global 'back' transition for the 3.0.0M1 version, and maybe you can find some good ideas in the feature requests or the posts referenced in it.

  5. #25

    Default

    This solution is great, but what if you only want to render a fragment rather than refresh the entire screen? Is it possible or is the approach Jeremy suggested the only one capable of leaving the flow in a consistent state?

    Thanks!

  6. #26
    Join Date
    Jul 2008
    Posts
    157

    Default

    I guess it's possible to do it.
    To render only fragments you have to use a transition in your flow definition, after all. So there must be some way to create a transition that will only render the fragments specified.

    You should put a breakpoint in the Transition class and debug a transition defined with render fragments to see what's going on and try to reproduce it.

    You should have a look at org.springframework.webflow.engine.builder.model.F lowModelFlowBuilder.parseTransition(TransitionMode l transition). It doesn't look like and easy task though.
    Maybe it is, but you'll have to go through a lot of parseXXXX methods to find what you need.
    Last edited by triqui; Aug 12th, 2010 at 03:51 AM.

  7. #27

    Default

    Thanks, but I've decided to stay with the approach of refreshing the screen. This way I can leverage the h:messages tag that is already on the string and I avoid having to code a transition in all my flows to handle my use case.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •