« How To Avoid The JBO-27014 Error During The AutoSubmit | Main | Application Lifecycle Management Tools Survey »

invokeAction Invoked Twice

Symptom

Suppose you published an Application Module method as a client method, f.ex.:
public void yourMethod() {
   System.out.println("Hello World");
}

You created an ADF Faces page and included the following in your page definition (<yourPage>PageDef.xml):
...
  <executables>
    ...
    <invokeAction Binds="yourMethod" id="executeYourMethodAction"
                  RefreshCondition="${!adfFacesContext.postback}"/>
    ...
  </executables>
  <bindings>
...
  <methodAction id="yourMethod" InstanceName="AppModuleDataControl.dataProvider"
                DataControl="AppModuleDataControl" MethodName="yourMethod"
                RequiresUpdateModel="true" Action="999"
                IsViewObjectMethod="false"/>
  </bindings>
</pageDefinition>

The aim is to execute yourMethod when the page first renders (controlled by the RefreshCondition).
The method is correctly executed, but you see it's executed twice.
The Log window of JDeveloper shows:
Hello World
Hello World 

Cause

The property Refresh is not defined for the invokeAction.
Its default value is ifNeeded, what means that the related action binding will be invoked twice during each request.


Solution


You should change the default Refresh setting for the invokeAction bindings to either prepareModel or renderModel.
With prepareModel, your invokeAction will be invoked before the JSF invokeApplication phase.
With renderModel, your invokeAction will be invoked after the JSF invokeApplication phase.

Since JSF's invokeApplication phase is when the JSF action events fire, you should decide if you want your invokeAction to trigger before (prepareModel) or after (renderModel) the action listeners have performed their processing,

For more information, see the ADF Develoepr's Guide, topic "10.5.5.3 Correctly Configuring Refresh Property of InvokeAction Executables"


Comments (2)

Kavin:

First of all, why the invokeAction is called twice when the refresh property is set to ifNeeded?

Hi Kavin,

that's per our ADF Framework design.
The ADF lifecycle doesn't know the purpose of your action. It doesn't know if it should be executed before or after the invokeApplication.
Hence it executes it twice by default.
However, we recommend to change this default, as explained in the ADF Developer's Guide.

Regards,

Didier

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on April 21, 2008 10:02 PM.

The previous post in this blog was How To Avoid The JBO-27014 Error During The AutoSubmit.

The next post in this blog is Application Lifecycle Management Tools Survey.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle