If I understand correctly, you want to better understand the sequence of events between the presentation layer (Javascript) and the controllers (Managed Beans).
This post Prime Faces' blog explains how the callback Ajax oncomplete
, onsuccess
and onstart
.
The general order would be as follows:
onstart
: request start event that executes a javascript.
actionListener
: updates properties on manabed bean.
action
: performs specified action of manabed bean.
onsuccess
/ onerror
: events javascript executed if there was a success or error in the 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, error or not
About action
and actionListener
A action
is the action where the business rules will effectively execute, usually culminating in a navigation. The method of action
usually returns a string.
The actionListener
is like an event that occurs before the action
in order to update values, perform some validation, log, etc. You can also cancel the action
if necessary. In a actionLisener
, you can access the values sent by the user through the parameter ActionEvent
before that JSF updates the properties of ManagedBean
.
I’ve seen some developers mistakenly access properties from ManagedBean
at the event actionListener
and record them in the database. Only then do they realize that the values are outdated.
The question is not very clear. The answer is what is on the link?
– bfavaretto
This has much more to do with Javascript / http requests and AJAX callbacks than with the JSF lifecycle. The API of each component (e. g., commandLink) indicates which tag attribute corresponds to each event type. Think of it as if there was no JSF in the middle (
onclick
is processed in the client before the request, then the ajax request happens -action
- you update the DOM -update
- and can do more -oncomplete
).– Anthony Accioly
Right, but is there any way, website, manual or anything like that?
– Macario1983
@bfavaretto yes, the answer of the link is my doubt, but the question of the link is not mine, it is more a curiosity. Because sometimes in a project using
JSF
withPrimefaces
, I come across a situation like, a button will be blocked or not if thedatatable
this filled....– Macario1983
@Anthonyaccioly I saw the
javadoc
, interesting, the information it contains describing on which side occurs the methods. But more information where I find? For example you said that theaction
updates the DOM...– Macario1983
In fact the
update
does (see utluiz response). To my knowledge there is no integrated manual detailing this (perhaps some book or course of Primefaces). I think this is because the documentation assumes a certain familiarity with JSF AJAX and Javascript (in theory the sequence should be intuitive). But take a look at User Guide. Especially in tagsAjaxBehavior
,AutoComplete
andCommandButton
, as well as in Chapter 4 - Partial Rendering and Processing and 6 - Javascript API. All the components end up being similar.– Anthony Accioly