Using Subforms to Create Regions on a Page

4-16 Web User Interface Developers Guide for Oracle Application Development Framework Figure 4–11 Relationship Between Scopes and Page Flow When determining what scope to register a managed bean with or to store a value in, always try to use the narrowest scope possible. Use the sessionScope scope only for information that is relevant to the whole session, such as user or context information. Avoid using the sessionScope scope to pass values from one page to another.

4.7 Passing Values Between Pages

The ADF Faces pageFlowScope scope makes it easier to pass values from one page to another, thus enabling you to develop master-detail pages more easily. Values added to the pageFlowScope scope automatically continue to be available as the user Note: If you are using the full Fusion technology stack, then you have the option to register your managed beans in various configuration files. For more information, see the Using a Managed Bean in a Fusion Web Application section of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework. Note: If you are using the full Fusion technology stack and you need information about passing values between pages in an ADF bounded task flow, or between ADF regions and pages, refer to the Getting Started With ADF Task Flows chapter of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework. Using the JSF Lifecycle with ADF Faces 4-17 navigates from one page to another, even if you use a redirect directive. But unlike session scope, these values are visible only in the current page flow or process. If the user opens a new window and starts navigating, that series of windows will have its own process. Values stored in each window remain independent. Like objects stored in any standard JSF scope, objects stored in the pageFlow scope can be accessed through EL expressions. The only difference with the pageFlow scope is that the object names must use the pageFlowScope prefix. For example, to have a buttons label provided by a managed bean stored in the pageFlow scope, and to have a method on the bean called when the button is selected, you might use the following code on your page: af:commandButton text={pageFlowScope.buttonBean.label} action={pageFlowScope.buttonBean.action} The pageFlowScope is a java.util.Map object that may be accessed from Java code. The setPropertyListener tag allows you to set property values onto a scope, and also allows you to define the event the tag should listen for. For example, when you use the setPropertyListener tag with the type attribute set to action, it provides a declarative way to cause an action source for example, commandButton to set a value before navigation. You can use the pageFlowScope scope with the setPropertyListener tag to pass values from one page to another, without writing any Java code in a backing bean. For example, you might have one page that uses the setPropertyListener tag and a command component to set a value in the pageFlowScope scope, and another page whose text components use the pageFlowScope scope to retrieve their values. You can also use the pageFlowScope scope to set values between secondary windows such as dialogs. When you launch secondary windows from, for example, a commandButton component, you can use a launchEvent event and the pageFlowScope scope to pass values into and out of the secondary windows without overriding values in the parent process.

4.7.1 How to Use the pageFlowScope Scope Within Java Code

You can access pageFlow scope from within any Java code in your application. Remember to clear the scope once you are finished. To use pageFlowScope in Java code: 1. To get a reference to the pageFlowScope scope, use the org.apache.myfaces.trinidad.context.RequestContext. getPageFlowScope method. For example, to retrieve an object from the pageFlowScope scope, you might use the following Java code: import java.util.Map; import org.apache.myfaces.trinidad.context.RequestContext; . . . Map pageFlowScope = RequestContext.getCurrentInstance.getPageFlowScope; Object myObject = pageFlowScope.getmyObjectName;

2. To clear the pageFlowScope scope, access it and then manually clear it.

For example, you might use the following Java code to clear the scope: Note: If your application uses ADF Controller, then you do not have to manually clear the scope.