2

Ok, so I have read

http://docs.oracle.com/javaee/7/tutorial/doc/jsf-configure003.htm

https://blogs.oracle.com/arungupta/entry/jsf_2_2_faces_flow

And a few more posts. The question that I couldn't get answered by reading these resources is:

How do I get rid of a flow by navigating to a random view? To clarify my question let me give an example.

Let's say I'm building an webapp that have a sidebar with a menu to all sort of things (crud for employees, crud for customers, and other cruds and reports).

Then I want to start a facesflow to properly handle the creation of a complex object, being this creation split in several views (BTW, I know how to start it). But how do I end the flow if the user clicks on, e.g, a link that generates a report that has nothing to do with the flow.

Will the flow be kept in memory? Will it be finished automatically by leaving the view associated with the flow?

Writing this question it came to my mind that the second option would be the best. If the users go to another view that has nothing to do with the flow, then the flow magically disappears.

Raidri
  • 17,258
  • 9
  • 62
  • 65
Bruno Krebs
  • 3,059
  • 1
  • 24
  • 36

2 Answers2

0

Ok, with the help of a coworker, I have (empirically) found the answer for this question.

The short answer:

You can leave the flow to whatever view you want, but if the flow is going to died or not depends on how you leave it. If you leave it through a post request to another view that is not in a flow, then the current flow will properly end.

BUT, if you leave it through a get request, to whatever view that is not in a flow, then the flow will not be closed, it will reside in memory.

I'll try to elaborate more as soon as possible.

UPDATE

Just to clarify, we have found this by using Java VisualVM and checking if the instances of a flow would persist or be collected by the GC.

Bruno Krebs
  • 3,059
  • 1
  • 24
  • 36
  • this is happening due to missing flow id in request. If you leave flow via GET request, flow will die, but after dertain amount of time. If you will create finalizer method in flow scoped bean, and within that method you will log some information, you will see, that after some time flow will be terminated. I'vie seen this in my project. – T.G Sep 22 '14 at 07:46
0

You are right, navigation within a flow or to a view outside of a flow requires either the usage of h:commandButton / h:commandLink or programmatic handling of the navigation. See this answer for an example.

This surely is a downside of Faces Flow, as navigation using GET should be the standard case.

Community
  • 1
  • 1
tasel
  • 629
  • 5
  • 15