Skip to content
Related Articles

Related Articles

What is JSF (JavaServer Faces)?
  • Last Updated : 13 Jan, 2021

JavaServer Faces application system oversees lifecycle stages consequently for straightforward applications and furthermore permits you to deal with that physically. The lifecycle of a JavaServer Faces application starts when the customer makes HTTP demand for a page and closures when the worker reacts with the page.  

The JSF lifecycle is partitioned into two fundamental stages:  

  1. Execute Stage
  2. Render Stage

1) Execute Stage  

In execute stage, when first solicitation is made, application see is fabricated or reestablished. For other resulting demands different activities are performed like solicitation boundary esteems are applied, transformations and approvals are performed for part esteems, overseen beans are refreshed with segment esteems and application rationale is conjured.  

The execute stage is additionally partitioned into following subphases.  



  • Restore View Stage
  • Apply request values Stage
  • process Approvals Stage
  • Update Model Qualities Stage
  • invoke Application Stage
  • Render Reaction Stage

Restore View Stage :

At the point when a customer demands for a JavaServer Faces page, the JavaServer Faces usage starts the reestablish see stage. In this stage, JSF fabricates the perspective on the mentioned page, wires occasion overseers and validators to segments in the view and saves the view in the FacesContext example.  

In the event that the solicitation for the page is a postback, a view relating to this page as of now exists in the FacesContext example. During this stage, the JavaServer Faces execution reestablishes the view by utilizing the state data saved money on the customer or the worker.  

Apply request values Stage :

In this stage, segment tree is reestablished during a postback demand. Segment tree is an assortment of structure elements.Each segment in the tree removes its new incentive from the solicitation boundaries by utilizing its disentangle (processDecodes()) strategy. After that worth is put away locally on every segment.  

On the off chance that any decipher techniques or occasion audience members have called the renderResponse strategy on the current FacesContext example, the JavaServer Faces usage jumps to the Render Reaction stage.  

On the off chance that any occasions have been lined during this stage, the JavaServer Faces usage communicates the occasions to intrigued audience members.  

In the event that the application needs to divert to an alternate web application asset or create a reaction that doesn’t contain any JavaServer Faces segments, it can call the FacesContext.responseComplete() strategy.  

In the event that the current solicitation is recognized as a halfway solicitation, the incomplete setting is recovered from the FacesContext, and the fractional handling technique is applied.  

Process Approvals Stage :

In this stage, the JavaServer Faces measures all validators enrolled on the segments by utilizing its approve () strategy. It looks at the segment ascribes that indicate the guidelines for the approval and thinks about these standards to the nearby worth put away for the segment. The JavaServer Faces additionally finishes changes for input segments that don’t have the prompt trait set to valid.  



if that any approve strategies or occasion audience members have called the renderResponse technique on the current FacesContext, the JavaServer Faces execution jumps to the Render Reaction stage.  

if that the application needs to divert to an alternate web application asset or produce a reaction that doesn’t contain any JavaServer Faces segments, it can call the FacesContext.responseComplete strategy.  

if that occasions have been lined during this stage, the JavaServer Faces execution communicates them to intrigued audience members.  

In the event that the current solicitation is distinguished as a fractional solicitation, the halfway setting is recovered from the FacesContext, and the incomplete handling strategy is applied.  

Update Model Qualities Stage : 

Subsequent to guaranteeing that the information is legitimate, it navigates the part tree and sets the comparing worker side article properties to the segments’ neighborhood esteems. The JavaServer Faces usage refreshes just the bean properties pointed at by an information part’s worth trait. On the off chance that the nearby information can’t be changed over to the sorts indicated by the bean properties, the lifecycle propels straightforwardly to the Render Reaction stage so the page is re-delivered with blunders showed.  

if chance that any updateModels techniques or any audience members have called the renderResponse() strategy on the current FacesContext occurrence, the JavaServer Faces usage jumps to the Render Reaction stage.  

In the event that the application needs to divert to an alternate web application asset or create a reaction that doesn’t contain any JavaServer Faces segments, it can call the FacesContext.responseComplete() technique.  

if that any occasions have been lined during this stage, the JavaServer Faces execution communicates them to intrigued audience members.  

if that the current solicitation is distinguished as a fractional solicitation, the incomplete setting is recovered from the FacesContext, and the halfway handling technique is applied.  

Invoke Application Stage :

In this stage, JSF handles application-level occasions, for example, presenting a structure or connecting to another page.  

Presently, if the application needs to divert to an alternate web application asset or produce a reaction that doesn’t contain any JSF segments, it can call the FacesContext.responseComplete() technique.  

From that point forward, the JavaServer Faces execution moves control to the Render Reaction stage.  

Render Reaction Stage:  

  • This is last period of JSF life cycle. In this stage, JSF assembles the view and delegates power to the suitable asset for delivering the pages.
  • On the off chance that this is an underlying solicitation, the segments that are spoken to on the page will be added to the part tree.
  • On the off chance that this is certainly not an underlying solicitation, the parts are now added to the tree and need not to be added once more.
  • In the event that the solicitation is a postback and blunders were experienced during the Apply Solicitation Esteems stage, Cycle Approvals stage, or Update Model Qualities stage, the first page is delivered again during this stage.
  • In the event that the pages contain h:message or h:messages labels, any lined mistake messages are shown on the page.
  • In the wake of delivering the substance of the view, the condition of the reaction is saved so ensuing solicitations can get to it. The saved state is accessible to the Reestablish View stage.

2) Render :

In this stage, the mentioned see is delivered as a reaction to the customer program. View delivering is a cycle in which output is produced as HTML or XHTML. In this way, client can see it at the program.  

  • The accompanying advances are taken during the render cycle.
  • Application is accumulated, when a customer asks for the index.xhtml page.
  • Application executes after arrangement and another segment tree is built for the application and put in a FacesContext.
  • The segment tree is populated with the segment and the oversaw bean property related with it, spoken to by the EL articulation.
  • In view of the segment tree. Another view is assembled.
  • The view is delivered to the mentioning customer as a reaction.
  • The segment tree is pulverized consequently.
  • On ensuing solicitations, the segment tree is revamped, and the saved state is applied.

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :