18-ADF Lifecycle
18-ADF Lifecycle
Section 18
Oracle ADF – ADF Lifecycle
ADF Lifecycle
Changed yes
View?
no
Render Response
ADF Lifecycle in Action
Restore View:
• Th
The URL ffor the
th requested t d page is
i
passed to the bindingContext.
• Page definition file that matches the
URL is looked up.
JSF Restore
R t View:
Vi
• Provides before and after phase events
• You can create a listener and register it with the before or after event
• The Initialize Context p
phase of the ADF Model layery lifecycle
y listens for the
after(JSF Restore View) event and then executes.
Initialize Context:
• The page definition file is read to create the bindingContainer
• The LifecycleContext class used to persist information throughout the
ADF lifecycle phases is instantiated and initialized with values for the
associated request, binding container, and lifecycle.
ADF Lifecycle in Action
Prepare Model:
• Binding container page parameters
are prepared and evaluated.
• Taskflow parameters are passed
into the flow.
• Any executables that have their
refresh attribute set to prepareModel are refreshed
• If the page was using a template, and that template contains bindings
th t use the
that th ADF M Model
d l llayer, th
then th
the ttemplate's
l t ' page d
definition
fi iti file
fil iis
initiated
• If any task flow executable bindings exist (for example, if the page
contains a region),
g ), the task flow binding g creates an ADF Controller
ViewPortContext object for the task flow, and any nested binding
containers for pages in the flow are executed.
ADF Lifecycle in Action
Invoke Application:
Any action
A ti bibindings
di ffor command
d
components or events are invoked
JSF Invoke Application:
Provides before and after phase events
MetaData Commit
• Changes to runtime metadata are committed
• This phase stores any runtime changes made to the application using the
M t d t Service
Metadata S i (MDS)
Initialize Context
• If navigation occurs
• Initialize page definition file for the next page
Render Response
JSF Render Response:
Provides before and after p
phase events
Specifying When to Refresh Binding
Executables
• Refreshing iterator reconnects it with RowSetIterator object
• Refreshing invoke action binding invokes the action
• Can set refresh property to refresh:
• deferred (default): During both Prepare Model and Prepare
Render phases
• prepareModel: Just during Prepare Model phase
• renderModel: Just during Prepare Render phase
• never: Only when code calls getRowSetIterator()
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF
Interacting
g with the ADF
Lifecycle
Using the Lifecycle
• Declarative
• Control execution via executables "Refresh" attribute
• prepareModel
• renderModel
• Code
• PagePhaseListener – Decorates the lifecycle
• Custom page controller - subclass and extend the lifecycle for
a page
• Use with caution remember to call the super-class!
p
• Complete custom lifecycle
Interacting with the ADF Lifecycle
import oracle
oracle.adf.controller.v2.lifecycle.PagePhaseEvent;
adf controller v2 lifecycle PagePhaseEvent;
import oracle.adf.controller.v2.lifecycle.PagePhaseListener;
<?xml version=
version="11.0
0" encoding=
encoding="US
US-ASCII
ASCII" ?>
<adf-settings xmlns="http://xmlns.oracle.com/adf/settings">
<adfc-controller-config
xmlns="http://xmlns.oracle.com/adf/controller/config">
<lifecycle>
<phase-listener>
p
<listener-id>CustomPageListener1</listener-id>
<class>adf.interactive.view.CustomPageListener</class>
<before-id-set>
<listener-id> AnotherPageListener1</listener-id>
</before-id-set>
<after-id-set>
<listener-id>AnotherPageListener2</listener-id>
</after-id-set>
</phase-listener>
</lifecycle>
</adfc-controller-config>
</adf-settings>
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF
Global Lifecycle
y
Customization
Lifecycle Customization
import oracle
oracle.adf.controller.v2.context.LifecycleContext;
adf controller v2 context LifecycleContext;
import oracle.adf.controller.faces.lifecycle.PageController;
Local Lifecycle
y
Customization
Custom Page Controller
import oracle
oracle.adf.controller.v2.context.LifecycleContext;
adf controller v2 context LifecycleContext;
import oracle.adf.controller.faces.lifecycle.PageController;
<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel"
version="…"
id="homePageDef"
Package="adf.sample.view.pageDefs"
ControllerClass="adf.sample.CustomPageController">
ll l df l ll
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF