Announcement Announcement Module
Collapse
No announcement yet.
Spring Faces best practice for error handling? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Probably you are trying to access a flow using a external url and get an exception.
    For instance you'll get that kind of error if you are handling AccessDeniedException and try to access a restricted flow directly.
    requestFlowExecutionRedirect will try to render the current view again, and it will throw an exception if the current State cannot be rendered. That is, if the state where the exception was thrown is not a view state or if there is no current state (like when you enter a flow directly from a link or bookmark, etc).

    You will see what is going on if If you try this while debugging:
    Code:
            String flowId = ex.getFlowId();
            String stateId = ex.getStateId();
            Event currentEvent = context.getCurrentEvent();
            StateDefinition currentState = context.getCurrentState();
            TransitionDefinition currentTransition = context.getCurrentTransition();
            State originationgViewState = (State)context.getRequestScope().get("webflow.originatingViewState");

    Comment


    • #17
      Thanks Triqui - that was the problem. The error was occurring on the on-start action, therefore the currentState was null.

      Steve

      Comment


      • #18
        redirect to MVC

        I have a requirment in which i want to redirect to MVC. Is there a way i can add MessageContext and redirect to external MVC and display error/info on MVC view?

        Comment


        • #19
          How does the suggested custom exception-handler solution fit with the exception-handling best practise stated by Keith Donald in thread 57026?

          "In general, the preferred way to do exception handling is to call web flow actions that catch service-layer exceptions, handle them as necessary, and return error events to the flow as appropriate. I tend to favor this over use of the xml exception handling in the flow with transition on-exeption and exception-handler tags."

          Comment


          • #20
            I am having this same problem "referenced bean x cannot be found", but I referenced it in webflow config like this:

            <bean name="AppExceptionHandler" id="AppExceptionHandler" class="pt.mycompany.dao.exceptions.AppExceptionHan dler">
            </bean>

            Does anyone know what's the problem? the application runs fine, it's just I have allways this annoying error in eclipse.

            Comment


            • #21
              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?

              Comment


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

                Comment


                • #23
                  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?

                  Comment


                  • #24
                    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.

                    Comment


                    • #25
                      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!

                      Comment


                      • #26
                        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, 04:51 AM.

                        Comment


                        • #27
                          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.

                          Comment

                          Working...
                          X