JSF Life Cycle
JSF life cycle is consist of 6 phases.
1.
Restore
View
2.
Apply
Request Values
3.
Process
Validations
4.
Update
Model Values
5.
Invoke
application
6.
Render
Response
Restore View:
A request
comes through the Faces Controller. A controller examine the request and get
the view ID.
JSF framework uses the view id to get all
components. If the view doesn't exist JSF create new view otherwise it used
existing view.
View is 3 types
·
new
view
·
initial
view
·
post
back
-->For new view
JSF builds the view for the faces page and event handlers and validator to the
components.
-->In case of initial
view (first time page is loaded)JSF create empty view and assign all
components with blank values. From the initial view JSF directly call the
render response phase
-->In case of post-back
(the user returned to the page he has accessed previously), the view
corresponding to the page is already exist so it needs to be store. The next
phase of post-back is apply request values.
Apply request values:
The purpose of this phase is for each component to
receive it's state. The components must first be retrieved or created from the
Faces context object. Components values typically retrieved from the request
and cookies and session.
--> the component immediate="false", and
component is bounded with integer then value is converted to integer if any
conversion fail then system adds the validation message to the Faces Context
and these message will be displayed in render response phase
--> The component immediate="true" all the
values converted to proper types and validated. The conversion value stored in
the component if fails it should store message in faces context object.
Process
Validations:
The first event handling takes place after the apply
request value phase. In this phase each component is having its values,
validated against to the application rules. This validation rules can be
predefined or mentioned by developer. If any component fails the validation
then message is added to the faces context and component is marked as invalid.
If any component is marked as invalid then JSF call the render response phase.
Update model
values:
This phase updates the all the model values. This phase
is executed after process validations, we can say that all the values are
validated.
Invoke
application:
JSF controller invokes the application to handle form
submissions. In this phase all the values are validated, updated so we can
execute our business logic.
Render
response:
This phase displays all the components with current
state.
No comments:
Post a Comment