This article tries to solve the issue of the repetitive invokeAction calling. In Oracle’s documentation guide can read:
To read more about this and more:
http://www.gebs.ro/blog/oracle/
Oracle recommends either adding an appropriate RefreshCondition expression (if you want it evaluated during both phases) or changing the default Refresh setting for invokeAction bindings to either prepareModel or renderModel, depending on whether you want your invokeAction to occur before or after the JSF invokeApplication phase.The Refresh property controls when the invokeAction will invoke the action binding:
- ifNeeded: its default value is ifNeeded, what means that the related action binding will be invoked twice during each request.
- prepareModel: your invokeAction will be invoked before the JSF invokeApplication phase
- renderModel: your invokeAction will be invoked after the JSF invokeApplication phase
#{adfFacesContext.postback==false}Even if you set this properties with the proper values presented above there are situations when your invokeAction is called twice. The solution is to redefine the RefreshCondition property by adding an extra condition. A counter method is defined in a backingBean related to your page which calls the invokeAction. This method increments its value at each call and returns true if its current value is 1 (when 2 we consider that the invokeAction was already called at the previous step, so return false). The backingBean must be in request scope.
#{adfFacesContext.postback==false and backingBean.countInvoke}
public boolean countInvoke() {There are other alternatives when you what to invoke methods from your backing bean or AMDataControl. If you have a taskFlow you can set method calls in your control flow case before rendering the page. In this situation you must deal with the situation of session expiring: if session expires in a page which has a method call in the task flow, after relogin, the user will be automatically redirected to the page without calling the methods from task flow (the same issue when you try to access directely from browser a page URL which must call before several method in task flow). Also you can try to set your call in f:view phases (afterPhase or beforePhase).
countInvoke = countInvoke + 1;
if (countInvoke == 1){
return true;
}
else{
return false;
}
}
To read more about this and more:
http://www.gebs.ro/blog/oracle/