Escolar Documentos
Profissional Documentos
Cultura Documentos
Problem Description
There are often times when application interaction is required between an ADF region
and its containing page. This communication typically involves initiating navigation or
sharing application data. Since an ADF region represents a separate task flow definition
with its own boundaries, any interaction across those boundaries must be considered
carefully. Depending on the specific ADF region interaction use case, different
approaches are utilized to implement the desired behavior. The many different
approaches involved under the umbrella of ADF region interaction can make selecting
the appropriate solution a challenge. This document describes each of these ADF region
interaction approaches to assist in determining which best fits any given situation.
If the initiation of navigation is required, the table below identifies the recommended
approach based on the corresponding region use case. Each approach is described further
within the document.
Navigation Recommended Approach
Navigate Root View Port (Browser) Task Flow URL View Activity
Navigate Containing Page From Region Task Flow Parent Action Activity
Navigate Region From Containing Page queueActionEventInRegion(…) Method
Identify Navigation Within Region regionNavigationListener
If data sharing is required, the table below identifies the recommended approach based on
the corresponding region use case. Each approach is described further within the
document.
Data Shared Recommended Approach
Entire Data Control Frame Task Flow Definition <data-control-scope>
Small Subset When Restarting Region Task Flow Definition Input Parameters
Task Flow
Small Subset Without Restarting Region Contextual Framework Events
Task Flow - or -
Task Flow Definition Input Parameters for Objects Passed By
Reference
Available Outcomes Based on Current Region Capabilities
State of Region
For further details on task flow URL view activities, refer to the Oracle Fusion
Middleware Fusion Developer's Guide for Oracle ADF within Section 14.3, "Using URL
View Activities".
Task flow parent action activities incorporate the following metadata within a task flow
source file:
<parent-action id="Exit">
<parent-outcome>globalHome</parent-outcome>
</parent-action>
For further details on task flow parent action activities, refer to the Oracle Fusion
Middleware Fusion Developer's Guide for Oracle ADF within Section 14.9, "Using
Parent Action Activities". Additional information can also be found in section 16.1.6
“How to Trigger Navigation of an ADF Region's Parent Task Flow”. Example used
taken from the Oracle Fusion Store Front Demo Application.
The contained region’s task flow definition includes the “Employees” and “Departments”
view activities along with the control flow between them. The
queueActionEventInRegion(…) method initiates the “employees” or “departments”
outcome depending on which button is selected. Based on the region’s current state, the
buttons are disabled accordingly using region capabilities.
The Java methods performed by the “Employees” and “Departments” buttons on the
parent page might be similar to the following:
Navigation – regionNavigationListener
An <af:region> regionNavigationListener is used if a containing page or page fragment
needs to identify when navigation occurs within a region. When the page fragment
displayed within a region changes an oracle.adf.view.rich.event.RegionNavigationEvent
is raised. The event provides both the old and new page fragment viewIds. Then the
RegionNavigationEvent triggers the regionNavigationListener EL method reference
specified on the <af:region> tag, if any. Therefore, any application logic required when
the region navigation can be incorporated into its regionNavigationListener.
For example, an <af:region> regionNavigationListener is required if the dynamic region
within an <af:popup> provides the ability to “exit” via navigation flow to task flow
return activities. The regionNavigationListener identifies when the region “exits” so the
<af:popup> can be programmatically dismissed without the user manually selecting its
close icon. Using the employee-update task flow definition below for the region, its
<af:region> regionNavigationListener should programmatically hide the <af:popup> after
executing either the “save’ or “cancel” task flow return activities to exit the task flow
definition.
type="popupFetch"/>
<af:panelWindow id="window" title="Employee Popup">
<af:region value="#{bindings.dynamicRegion1.regionModel}" id="dynam1"
regionNavigationListener="#{pageFlowScope.PopupDynamicRegionBean.navigationListener}"/>
</af:panelWindow>
…
</af:popup>
The regionNavigationListener Java method would be similar to the following. The
method identifies when the region exists via task flow return activity (“newViewId ==
null”) and then programmatically hides the <af:popup>.
} while (!found);
if (found) {
For further details on the task flow definition <data-control-scope> property, refer to the
Oracle Fusion Middleware Fusion Developer's Guide for Oracle ADF within Section
15.3, "Sharing Data Control Instances".
Once raised, contextual framework events are passed to their binding container for
dispatch. The binding container’s contextual framework event dispatcher checks the
event map defined within the binding containers page definition file for interested
consumers. After checking the same binding container where the contextual framework
event was raised, event propagation is then delegated to check for consumers within the
parent binding container event map. This process continues until the topmost parent
binding container is reached. After the topmost binding container is reached, the
contextual framework event is then dispatched to child region binding containers to check
event maps defined with an event producer set to wildcard "*". If interested consumers
are identified, the contextual framework event is delivered to the consumers at the end of
the ADF lifecycle. Contextual framework events are always consumed by methods.
Event Producer
Contextual framework events are produced by page definition action bindings, method
action bindings, value attribute bindings, tree bindings, table bindings, or list bindings. In
the example below, the queueHelpTopic event is defined within the setHelpId
methodAction binding. When the methodAction binding is executed, the contextual
framework event will be raised. The methodAction passes in a “usage” parameter and
returns a corresponding HelpId value. The HelpId methodAction result will be placed
within the contextual framework event payload and passed along to any event consumers.
<methodAction id="setHelpId"
InstanceName="LookupServiceAMDataControl.dataProvider"
DataControl="LookupServiceAMDataControl"
RequiresUpdateModel="true" Action="invokeMethod"
MethodName="setHelpId" IsViewObjectMethod="false"
ReturnName="LookupServiceAMDataControl.methodResults.setHelpId_LookupServiceAMDataC
ontrol_dataProvider_setHelpId_result">
<NamedData NDName="usage" NDValue="CREATE_PROFILE"
NDType="java.lang.String"/>
<events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
<event name="queueHelpTopic"/>
</events>
</methodAction>
The setHelpId method executed by the methodAction binding might be similar to the
following:
return (Long)helpRow.getAttribute("HelpId");
}
Event Map
Contextual framework event maps relate together the producer and consumer of a given
event. The consumer handler will be a specified method. If the producer or consumer is
not contained within a region, the “region” attribute is not needed within the event map
<producer> and <consumer> elements. In the example below, the eventMap relates the
queueHelpTopic event producer to its consumer. The producer is identified as any
region. The consumer is identified as the helpPageDef.findHelpTextById method
binding within the helptaskflow1 region. The helpTopicId parameter of the consumer
method is assigned the value of the contextual framework event payload passed from the
producer.
<eventMap xmlns="http://xmlns.oracle.com/adfm/contextualEvent">
<event name="queueHelpTopic">
<producer region="*">
<consumer region="helptaskflow1"
handler="helpPageDef.findHelpTextById">
<parameters>
<parameter name="helpTopicId" value="${payLoad}"/>
</parameters>
</consumer>
</producer>
</event>
</eventMap>
Instead of manually creating page definition event map metadata, the JDeveloper Event
Map Editor can also be used to greatly simplify the procedure. To access the Event Map
Editor, add an eventMap element to a page definition in JDeveloper. Then in the
eventMap element Property Inspector select the Edit toolbar button.
The Event Map Editor dialog will be displayed to Edit an existing event or Add a new
event within the event map.
After selecting the Event Map Editor Edit or Add toolbar buttons, the Modify Event Map
Entry dialog is displayed. It makes modifying or creating event map metadata easier by
using dropdowns for the selection of the event, its producer, and its consumer. The
dropdowns incorporate values from the current page definition, but also the page
definitions of any child regions. The dropdowns; however, currently don’t incorporate
values from any dynamic regions. Those must be entered manually.
Event Consumer
The contextual event consumer will always be a method. Parameter values of the method
can be assigned by the event map using the contextual framework event payload. In the
example below, the contextual framework event consumer is the findHelpTextById
methodAction binding. It passes in a helpTopicId and returns the corresponding
HelpText. The value of the helpTopicId parameter is assigned within the event map as
the value of the contextual framework event payload. The value of the payload was set
when the event was raised by the result of the producer method.
<methodAction id="findHelpTextById"
Action="invokeMethod" MethodName="findHelpTextById"
IsViewObjectMethod="false"
DataControl="LookupServiceAMDataControl"
InstanceName="LookupServiceAMDataControl.dataProvider"
ReturnName="LookupServiceAMDataControl.methodResults.findHelpTextById_LookupServiceA
MDataControl_dataProvider_findHelpTextById_result">
<NamedData NDName="helpTopicId" NDValue="" NDType="java.lang.Long"/>
</methodAction>
The findHelpTextId method identified as the event consumer might be similar to the
following:
For further details on implementing contextual framework events, refer to the Oracle
Fusion Middleware Fusion Developer's Guide for Oracle ADF within Section 26.5,
"Creating Contextual Events". Example used taken from the Oracle Fusion Store Front
Demo Application.
Region capabilities require the availability of the specified regions regionModel through
an EL Expression. An EL expression should never access bindings in any binding
container other than the current binding container (e.g.: #{bindings.taskflowdefinition1}).
Therefore in cases where a regionModel cannot be reached within the current binding
container (e.g.: nested regions), region capabilities cannot be used. This is because a
nested regions nested binding container might not exist yet or might have already been
released.
EL Expression syntax:
#{bindings.taskFlowBinding.regionModel.capabilities}
EL Expression syntax:
#{bindings. taskFlowBinding.regionModel.actions}
In the example described previously, the “Employees” button disabled attribute was
assigned the region capabilities EL Expression shown below. It disables the
“Employees” button if the “departments” outcome is currently available within the
taskflowdefinition1 region (i.e.- the “Departments” button should be enabled and the
“Employees” button disabled).
<af:commandButton text="Employees"
disabled="#{bindings.taskflowdefinition1.regionModel.capabilities['departments']}" />
For further details on region capabilities, refer to the Initiate Control Flow within a
Region from its Parent Page pattern document on OTN or the
oracle.adf.view.rich.model.RegionModel class.
Related Patterns
Embedding Regions Inside Popup Windows
Initiate Control Flow within a Region from its Parent Page
Related Documentation
Documentation Related to the Pattern Artifacts
Task Flow URL View Activities Section 14.3, "Using URL View
Activities" in the Fusion Developer's
Guide for Oracle ADF
Task Flow Parent Action Activities Section 14.9, "Using Parent Action
Activities" in the Fusion Developer's
Guide for Oracle ADF
<af:region> Tag Oracle ADF Faces <af:region> Tag
Documentation.
Task Flow Definition <data-control- Section 15.3, "Sharing Data Control
scope> Instances" in the Fusion Developer's
Guide for Oracle ADF
Task Flow Definition Input Parameters Section 15.2, "Passing Parameters to an
ADF Bounded Task Flow" in the Fusion
Developer's Guide for Oracle ADF
taskFlow Binding Refresh and Section 16.1.7, "What You May Need to
RefreshCondition Attributes Know About Refreshing an ADF Region"
in the Fusion Developer's Guide for Oracle
ADF
Contextual Framework Events Section 26.5, "Creating Contextual
Events" in the Fusion Developer's Guide
for Oracle ADF
RegionModel oracle.adf.view.rich.model.RegionModel
class