Announcement Announcement Module
Collapse
No announcement yet.
destroy flow Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • destroy flow

    Hi,
    I'm looking for a methodology that help me to destroy a flow.
    I show the opened flows with a modal panel, although I would like can close or destroy one flow. e.g. If I have a 5 flows opened, I show these flows with a modal panel, I show the link / and a image close (cross). I want to click to cross and I can to close this flow. How can I do this?
    I've shearched information but I've not found anything.

    Thank you very much!

  • #2
    You end (and destroy) a flow by ending the top-level flow. If you're only working with a top-level flow, you'll need to define an end-state, and create a global transition to your end-state. Pressing on the X should drive the global transition to your end state and end the flow.

    If any of your flows invoke subflows, you'll probably need to use a combination of what I suggested above with flow inheritance. The global transition and the end-state can go into the parent flow, and all your other flows can inherit it. The name of the event associated with the global transition should match the name of the end-state. That way, when you click the X, it drives the transition in the subflow as defined by its parent, and hits the parent's end-state, ending the subflow and bubbling control up to the calling flow. This repeats, and control keeps on bubbling up as subflows return until the top-level flow ends.

    Comment


    • #3
      Thank you for your answer!

      I've done it with end-flow!!!

      Comment


      • #4
        Hi, i've got a similar question:

        I've got multiple flows open, they are not directly related to each other. I have a List of the Flow Keys and Ids and display the active flows on the page.

        If i want to close a single Flow I invoke the transition to the end-state by sending a request to it.

        Now my question is: How can i close multiple flows? Is there some way to do this(invoke transitions on flows) outside the Webflow itself; in a @Service for example?

        I don't want to send requests to different Flows invoking each with a single transition to its end-state.

        Comment


        • #5
          Hmn is there really no simple solution for this?

          Comment


          • #6
            No simple solution, as far as I can tell. Spring Web Flow was not really designed for this case. You'll likely need to get the source and javadocs and dig around and see if there's some way to get a hold of the Conversation you want to end. As the Javadocs say, once you get a reference to the conversation, you'll need to acquire the lock on it before calling its end() method.

            Comment


            • #7
              Thx for the reply.
              I'll see what i can find

              Comment


              • #8
                So just to report back: I found some kind of solution, no idea if its a good one or even a real-real one but anyway:

                Code:
                //  Obtain the FlowExecutor from the ApplicationContext
                FlowExecutorImpl flowExecutor = (FlowExecutorImpl) xmlCtx.getBean("flowExecutor);
                Code:
                // Then you get the flowRepository for access to the active Flows
                FlowExecutionRepository flowRepository = flowExecutor.getExecutionRepository();
                For each flow you want to close you need to provide the FlowKey (get it via FlowExecutionKey flowKey = flowRepository.parseFlowExecutionKey(".."); for example).

                Code:
                // then you programmatically remove the flow:
                FlowExecutionLock flowLock = flowRepository.getLock(flowKey);
                flowLock.lock();
                try {
                        FlowExecution flowExecution = flowRepository.getFlowExecution(flowKey);
                        flowRepository.removeFlowExecution(flowExecution);
                } finally {
                        flowLock.unlock();
                }
                and hope it gets closed, destroyed and garbage-collected afterwarads.. ;D

                Seems to work for me, maybe someone can confirm, or provide an easier/cleaner solution to do this.

                Comment


                • #9
                  Very useful for parallel flows

                  Originally posted by afe View Post
                  So just to report back: I found some kind of solution, no idea if its a good one or even a real-real one but anyway:

                  Code:
                  //  Obtain the FlowExecutor from the ApplicationContext
                  FlowExecutorImpl flowExecutor = (FlowExecutorImpl) xmlCtx.getBean("flowExecutor);
                  Code:
                  // Then you get the flowRepository for access to the active Flows
                  FlowExecutionRepository flowRepository = flowExecutor.getExecutionRepository();
                  For each flow you want to close you need to provide the FlowKey (get it via FlowExecutionKey flowKey = flowRepository.parseFlowExecutionKey(".."); for example).

                  Code:
                  // then you programmatically remove the flow:
                  FlowExecutionLock flowLock = flowRepository.getLock(flowKey);
                  flowLock.lock();
                  try {
                          FlowExecution flowExecution = flowRepository.getFlowExecution(flowKey);
                          flowRepository.removeFlowExecution(flowExecution);
                  } finally {
                          flowLock.unlock();
                  }
                  and hope it gets closed, destroyed and garbage-collected afterwarads.. ;D

                  Seems to work for me, maybe someone can confirm, or provide an easier/cleaner solution to do this.

                  Thanks for the useful tips. This is actually useful in multiple parallel flow scenarios.

                  Comment


                  • #10
                    How do we parse the flow execution key?

                    How do we get the encoded key to be passes as parameter to parseflowexecutionkey?

                    any help would be great.

                    Thank you.

                    Comment


                    • #11
                      Originally posted by aragonknight View Post
                      How do we parse the flow execution key?

                      How do we get the encoded key to be passes as parameter to parseflowexecutionkey?
                      Hi,

                      In our case we implemented a CustomFlowListener. Within its sessionStarted(RequestContext context, FlowSession session) Method you can retrieve the FlowKey:
                      Code:
                      FlowExecutionKey executionKey = context.getFlowExecutionContext().getKey();
                      String key = executionKey.toString();
                      We then manage the flowKeys ourselves and display active flows in a menu. When a flow should be closed from outside you can get it's flow key (string representation that then needs to be parsed) from your own storage.

                      When a flow is normally closed, CustomFlowListener.sessionEnded is called and you can remove the flowKey from your storage from within there.

                      Comment


                      • #12
                        Thanks Afe.

                        Comment

                        Working...
                        X