Announcement Announcement Module
Collapse
No announcement yet.
Access end-state Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Access end-state

    Hi!

    After a flow termination, I need to access the State object of the end-state, that terminated the flow.

    Right now, I am using the

    Code:
    ResponseInstruction.getFlowExecutionContext().getActiveSession().getState()
    method to get this information after submiting an event to the FlowExecutor. However, this doesn't work when the flow is closed after reaching an end-state. is there any way to access the State object of that end-state anyways?

    Thanks

    Robert

  • #2
    Access end-state

    Once the end-state is reached, the flow is terminated. If you want to access any object before end-state, you should do it in the transition that calls the end-state.

    Example:

    Code:
    <some-state>
    ...
    <transition on="something" to="endstate">
      <action bean="someBean" method="yourAccessMethod">
    </transition>
    </some-state>
    
    <end-state id="endstate"/>
    Make sure to return success() from yourAccessMethod if you want the transition to succeed (ie reach the endstate).

    JL

    Comment


    • #3
      The end state ends the flow execution so you can no longer access it via the "active session" since there no longer is an active session.

      One thing you could do is store the necessary info (e.g. end state id) in the request or flash scope in an entry action of the endstate. That way it will be available in the view that is rendered by the end state.

      Erwin

      Comment


      • #4
        Yes, but...

        I concur, but this is only feasible, if there is a plain flow definition with at least one more state, that is not an end-state.

        However, your hint made me think of another solution. An end-state could have an entry action, that could save the State object with RequestContext.getCurrentState() prior to the flow termination. But then I need an entry action in EVERY end-state, which sort of restrains the design of the page flow.

        A solution enabling access to the terminating view state after the flow termination would be somehow neater ;-)

        Robert

        Comment


        • #5
          oops

          @Erwin: seems like I posted the same idea while you wrote your post :-)

          However, thanks to both of you (Erwin and JL)

          Comment


          • #6
            If you're feeling adventurous, you have a few other options:

            - you could plug in a custom EndState implementation that saves it's state id in some scope
            - you could use a FlowExecutionListener

            Erwin

            Comment


            • #7
              I like the idea with the FlowExecutionListener. If I understad that correctly, the FlowExecutionListener's sessionEnded() method is called upon reaching an end-state and terminating the flow execution. I can assign such a listener by assigning the FlowExecutionListenerLoader in the ContinuationFlowExecutionRepositoryFactory class, and use it to construct my FlowExecutor.

              Right? I'll go try that...

              Comment


              • #8
                That's right.

                Erwin

                Comment

                Working...
                X