What exactly does the pageflowScope do in ADF Faces?

17,029

Solution 1

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.

Solution 2

Simply :

pageFlowScope: This scope will be available as long as the user navigating from one page to another. If the user opens a new browser window and begins navigating, that series of windows will have their own pageFlowScope scope.

  1. Every ADF task flow instance is granted with its own Page Flow Scope

  2. Page Flow Scope is not destroyed when you navigate away from the task flow, unless you use Task Flow Return activity and finalizer is invoked

  3. You can access previously left Page Flow Scope only by using Task Flow Return activity.

How to programmatically access pageFlowScope objects

    AdfFacesContext context= AdfFacesContext.getCurrentInstance();
    Map pageFlowScope = context.getPageFlowScope();
    pageFlowScope.put("Name","myName");

Solution 3

In addition to those above posts, main usage of pageFlowScope is ADF bounded taskflow has different activities. example view, method call, task flow return etc.

PageFlowScope is used to share the data between activities in the task flow. Also input parameter and output parameters of the task flow are stored in the pageflow scope.

Solution 4

ADF has the concept of a task-flow where you can put together some related pages with navigation rules. The page-flow scope covers the execution of such a task-flow. This can take longer than a request and can span multiple views, so this scope is longer than request and view scope, but is smaller than session scope. The scope is destroyed when you navigate away from the pages that compose the task-flow. As a very simple use case think of a wizard where you have to fill in a couple of pages of data before submitting the final result for processing.

Share:
17,029
Geek
Author by

Geek

Updated on June 26, 2022

Comments

  • Geek
    Geek almost 2 years

    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 ?