LIFECYCLEEXCEPTION:JSF Source code Appreciation of lifecycle

Source: Internet
Author: User
Tags class definition

The JSF lifecycle plays a vital role in JSF applications, and each JSF request is processed through a lifecycle, and this article analyzes the JSF lifecycle from a source perspective.
Before we discuss the lifecycle, let's discuss some of the elements of Facescontext, who play a very important role throughout the lifecycle. A JSF application must save the requested information it processes, Facescontext saves all the necessary contextual information for processing requests and generating responses, specifically, it includes:
1. Information queue, MessageQueue, save all messages
2. The current component tree, Viewroot,
3. External context, Externalcontext
4.Application.
Here are the variables in Sun's Facescontextimpl:
Com.sun.faces.context.FacesContextImpl:
Relationshipinstancevariables
Privateresponsestreamresponsestream=null;
Privateresponsewriterresponsewriter=null;
Privateexternalcontextexternalcontext=null;
Privateapplicationapplication=null;
Privateuiviewrootviewroot=null;
Privateelcontextelcontext=null;
Privaterenderkitfactoryrkfactory;
PRIVATERENDERKITLASTRK;
Privatestringlastrkid;

/**
*storemappingofclientidtoarraylistoffacesmessage
*instances. Thenullkeyisusedtorepresentfacesmessageinstances
*thatarenotassociatedwithaclientidinstance.
*/
privatemap>componentmessagelists;
Attributeinstancevariables

Privatebooleanrenderresponse=false;
Privatebooleanresponsecomplete=false;
There are a lot of important objects that we should study, and in order from top to bottom, let's look at Externalcontext first.
Externalcontext is actually an encapsulation of servletcontext (or Portletcontext) that provides various ways to access external container resources, externalcontext the base class definition as follows:
Javax.faces.context.ExternalContext:
publicabstractclassexternalcontext{


Publicstaticfinalstringbasic_auth= "BASIC";
Publicstaticfinalstringclient_cert_auth= "Client_cert";
Publicstaticfinalstringdigest_auth= "DIGEST";
Publicstaticfinalstringform_auth= "FORM";

----------------------------------------------------------Publicmethods
Publicabstractvoiddispatch (Stringpath)
Throwsioexception;
Publicabstractstringencodeactionurl (StringUrl);

Publicabstractstringencodenamespace (Stringname);
Publicabstractstringencoderesourceurl (StringUrl);
Publicabstractstringgetauthtype ();
Publicabstractobjectgetcontext ();
Publicabstractstringgetinitparameter (Stringname);
Publicabstractmapgetinitparametermap ();
Publicabstractstringgetremoteuser ();
Publicabstractobjectgetrequest ();
Publicvoidsetrequest (objectrequest) {
Externalcontextimpl;
if (null!= impl= (Externalcontext) This.getrequestmap ().
Get ("Com.sun.faces.ExternalContextImpl"))) {
Impl.setrequest (Request);
Return
}

Thrownewunsupportedoperationexception ();
}
Publicvoidsetrequestcharacterencoding (stringencoding) throwsunsupportedencodingexception{
Externalcontextimpl;
if (null!= impl= (Externalcontext) This.getrequestmap ().
Get ("Com.sun.faces.ExternalContextImpl")) {This article links http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20130620/38738.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.