By Arunkumar Ramamoorthy-Oracle on Jun 21, 2012
In this blog, we will go through different options in achieving it.
1. Method Call Activity as default activity in Taskflow :
If the application is built with taskflows, then this is the best suited approach to take.
1.a. Calling a Data Control Method :
To call a Data Control method (ex: A method in AMImpl exposed as client interface), simply Drag and Drop the method as Default Method Call Activity, then draw a control flow case from the method to your page.
1.b. Calling a Method in Backing Bean:
To call a method in the backing bean before pageload, we can follow the similar approach as above. Instead of binding the Method Call Activity to an action/method binding in pagedef, we bind to the method. Insert a Method Call Activity (and make it as default) from the Component Palette. Double click on to select a method to bind.
This approach can also be used, to perform some action in backing bean along with calling a method Data Control (just need to add bindings code in backing bean to execute DC method).
2. Using invokeAction Executable :
If the application is built with pages and no taskflows are involved, then this option can be taken into consideration.
In the page definition of the page, add an invokeAction Executable and bind it to the method needed to be executed.
3. Using combination of Server and Client Listeners :
If the page does not have any page definition, then to call a method in backing bean, this approach can be taken. In this, a serverListener would be added at the document level, which would be calling the method in backing bean. Along with this, a clientListener would be added with "load" type (i.e will be triggered when the page loads), which would queue a serverEvent to trigger the method.
4. Using Page Phase Listener :
This should be the last resort. Care should be taken when using this approach since the Phase Listener would be called for each request sent by the client.
Zeeshan Baig's blog covers this scenario.