In Oracle ADF framework developer can use standard JSF listener or special ADF listener which supports additional ADF-specific page cycle extensions. Listeners can be used to customize the ADF Lifcycle.
Custom listener can beconfigured for the following scopes:
- Global, when the page lifecycle listener is configured to execute for all lifecycle execution throughout the application
- Page scope - the listener is configured in the page definition file and supports concrete page
- Custom scope - a lifecycle listener is added programmatically from Java and remains active until it is removed or the user session is dismissed
- Create an objects that should receive lifecycle notifications. The object must implement the PagePhaseListener interface
- The method argument is an instance of PagePhaseEvent.
- PhaseId returns phase identifier (int value)
- ADF controller is requred
- To create and configure global lifecycle listener use the adf-settings.xml configuration file. The adf-settings.xml file does not exist by default and needs to be created in the “.adf\META-INF” folder of the application. The adf-settings.xml file allows developers to define the order in which page phase listeners are invoked.
public class MyPageListener implements PagePhaseListener { public MyPageListener() { super(); } public void afterPhase(PagePhaseEvent pagePhaseEvent) { String phaseId = pagePhaseEvent.getPhaseId(); System.out.println("We are after "+ Lifecycle.getPhaseName(phaseId)); } public void beforePhase(PagePhaseEvent pagePhaseEvent){ String phaseId = pagePhaseEvent.getPhaseId(); System.out.println("We are before "+ Lifecycle.getPhaseName(phaseId)); } }
<?xml version="1.0" encoding="US-ASCII" ?> <adf-settings xmlns="http://xmlns.oracle.com/adf/settings"> <adfc-controller-config xmlns="http://xmlns.oracle.com/adf/controller/config"> <lifecycle> <phase-listener> <listener-id>MyPageListener1</listener-id> <class>mc.adf.listeners.MyPageListener</class> <before-id-set> <listener-id> MyPageListener2</listener-id> </before-id-set> <after-id-set> <listener-id>MyPageListener3</listener-id> </after-id-set> </phase-listener> </lifecycle> </adfc-controller-config> </adf-settings>
No comments:
Post a Comment