This post is intended to load the life cycle of ADF in to the brain.
Phase I .Restore View Phase
=============================
During this phase builds the component tree of view and wires the component to the validator, converters and Listeners to the components in the view , and stores the view in the ADFFacesContext object.
Two Types of request :
1.Initial Request : It creates empty view and life-cycle advanced to the Render Response Phase.
2.Post Back Request : During this request the view exist in the ADFFacesContext objcet , hence it restores the view from the client or server.


Phase I .Restore View Phase
=============================
During this phase builds the component tree of view and wires the component to the validator, converters and Listeners to the components in the view , and stores the view in the ADFFacesContext object.
Two Types of request :
1.Initial Request : It creates empty view and life-cycle advanced to the Render Response Phase.
2.Post Back Request : During this request the view exist in the ADFFacesContext objcet , hence it restores the view from the client or server.
Phase II. Apply Request Value
=======================
After the component tree is restored during the post-back request each component in the tree
extract its new value from the request parameter by using decode method.The value is then stored on each component.
If immediate=true is set on any component then the validation ,conversion and event association with this component processed into this phase.
At this point, if the application needs to redirect to a different web application resource or generate a response that does not contain any Java-server Faces components, it can call the FacesContext.responseComplete method
Phase III. Process Validation Phase
==========================
During this phase It process all validators registered on component in the tree using validate
processValidatate method. It examines the the component attribute that's specify the rules for the validations and compares the rule against the value stored in the component and also completes the conversions on the component .If the local value is invalid or conversion failed in this phase then life cycle directly advance to the render response phase , to render the error message.
At this point, if the application needs to redirect to a different web application resource or generate a response that does not contain any Java-server Faces components, it can call the FacesContext.responseComplete method.
Phase IV.Update Model
====================
During this Phase implementation determines that the data is valid, it traverses the component tree and sets the corresponding server-side object properties to the components' local values.
It updates only the bean properties pointed at by an input component's value attribute.
If the local data cannot be converted to the types specified by the bean properties, the lifecycle
advances directly to the Render Response phase so that the page is re-rendered with errors displayed.
At this point, if the application needs to redirect to a different web application resource or generate a response that does not contain any Java-server Faces components, it can call the FacesContext.responseComplete method.
Phase V. Invoke Application .
=========================
During this phase implementation handles any application-level events, such as submitting a form or linking to another page.
At this point, if the application needs to redirect to a different web application resource or generate a response that does not contain any Java-server Faces components, it can call the FacesContext.responseComplete method.
Phase VI. Render Response Phase
==========================
This phase build the view and delegates the task of rendering to appropriate resource.
If this is an initial request, the components that are represented on the page will be added to the component tree (ADFFacesContext). If this is not an initial request, the components are already added to the tree and need not be added again.
If the request is a post-back and errors were encountered during the Apply Request Values phase, Process Validations phase, or Update Model Values phase, the original page is rendered again during this phase. If the pages contain h:message or h:messages tags, any queued error messages are displayed on the page.
After the content of the view is rendered, the state of the response is saved so that
subsequent requests can access it. The saved state is available to the Restore View
phase.
What happens when you click on reset button ?
1.It fires the validation on the name and date field in the phase of process validation by going through the life cycle.
2. The fields are not cleared.
What expected when we click on the reset button?.
-- The validation on the name and date field should not be trigger that is we want to skip the some of the life cycle phases (Process Validation and Update Model).
-- The Name and Date field should be cleared .
What about Immediate="True" ? What is it ? What will happen ?
Immediate=true
An immediate command executes the action and action listener in Phase II Apply Request Value. and then jumps to phase VI. Render Response by skipping the validation , update model and invoke application .
<af : CommandButton text="Reset" id="cb2" immediate="true"
actionListener="#{}"/>
And Action Listener Code :
public void reset(ActionEvent event){
setName(NULL);
setDate(NULL);
setHelloMessage(NULL);
}
Now what will happen when I am clicking on the Reset Button ?
and here is out put
When executing an immediate command the UI component do not re-evaluate their underlying binding , so showing stealing value.
Three options are there to solve this problem :
1. Use af:resetActionListener
2. oracle.adf.view.rich.util.ResetUtils.reset()
3. UIComponent.resetValue()
Re-commanded : af:resetActionListener does NOT reset child regions, use ResetUtils.reset() instead.
Continue to post Comprehensive ADF Life Cyle Demo :Post II
Very appropriate illustrations!
ReplyDeleteone question - will immediate=true actually skip validations or will it do the validations in the apply request values phase only?
ReplyDeleteGood web site you possess in here…
ReplyDeletesccm training
sccm online training