How do I find out the order of running methods in jsf ? My question is based on the following, one time a button was firing late a method as it had not chosen the button method correctly.
In this link the guy responds to the execution sequence.
If I understand you correctly, you want to better understand the sequence of events between the presentation layer (Javascript) and the managed beans.
This post from the Prime Faces blog explains the workings of callback Ajax events oncomplete
, onsuccess
and onstart
.
The general order would be as follows:
onstart
: start event of the request that executes a javascript. actionListener
: updates properties in manabed bean . action
: performs specified action of manabed bean . onsuccess
/ onerror
: javascript events executed if there was success or error in action, respectively. update
: Updates DOM components to reflect actions performed via javascript, but can call methods used by updated components via postback . oncomplete
: javascript event executed after everything was completed, with error or not action
and actionListener
A action
is the action where business rules will effectively execute, usually culminating in navigation. The action
method usually returns a String.
actionListener
is like an event occurring before action
in order to update values, perform some validation, log, etc. You can still cancel the action
if necessary. In actionLisener
, you can access the values sent by the user through the parameter ActionEvent
before that JSF update the properties of ManagedBean
.
I've seen some developers mistakenly access properties of ManagedBean
in the actionListener
event and write them to the database. Only then do they realize that the values are out of order.