jsfjsf-2oracle-adftrinidad

What exactly does the pageflowScope do in ADF Faces?


ADF faces exposes a new scope(called pageflow) in additon to to the normal session,request,view scopes for managed beans. What does this scope do ? What are its pros and cons ? When do objects put inside pageflowScope get garbage collected ?


Solution

  • pageFlowScope beans are scoped to the ADF controller concept of "task flows", that being the unbounded task flows (UTF) or bounded task flows (BTF). In ADF a task flow is a collection of pages or page fragments brought together in a flow, or in other words a defined set of activities including routers, method calls and page/page fragments calls.

    The pageFlowScope lifecycle/scope is that of the task flow. They come into existence when they are first accessed via code or EL (not necessarily the beginning of the task flow) in the task flow, and fall out of scope when the task flow exits (or the user logs out or the session times out). As task flows can call task flows in a stacked fashion, there can be serval pageFlowScope beans in play at any one time.

    There isn't so much advantages/disadvantages of pageFlowScope, but rather when you should use them or not. pageFlowScope beans carry state for the task flow and allow the task flow's state to be separate from the larger scoped session and applicationScope beans, and not recreated as frequently as the lesser scope request, backingBean and view scoped beans. As example incoming and outgoing parameters of the task flow are ideal to be stored in pageFlowScope. As a counter example values to be manipulated on the current page, would be better placed in request/backingBean/view scope.

    Another advantage of pageFlowScope beans is they are aware of multi-browser tabs. If the same session has two instances of the application open in separate browser tabs, ADF will spawn two separate pageFlowScope beans for each tab, unlike sessionScope which will only spawn one. This allows the task flows to have independent state on each tab.

    Finally addressing your last question, the objects within a pageFlowScope bean only become available for garbage collection when the pageFlowScope bean itself falls out of scope, that is when the task flow exits, the user logs out, or the session times out. Of course the usual caveats apply if an indirect handle is kept on the pageFlowScope bean by the programmer, the bean wont be a candidate for garbage collection until this occurs.