JSF Tutorial (9)-life cycle process validations Phase

Source: Internet
Author: User
Tags event listener

in this processJSFthe implementation of the userprocessvalidatorsmethod to handle allTreeThe validator that is registered in the component in the. The process of validation is verifying the values that have been saved by the rules that are already in each component, as well as verifying the values entered, provided that the component'sImmediateproperty is not set totrue. From the code point of viewUiviewrootin thisprocessvalidatorsmethod and the previous stage of theProcessdecodesbasically consistent, needless to say the next stage (Update modelvalues Phase) There will also be similar methods (processupdates). The reasonJSFThis is done because the three phases (value, checksum, update) do things for each component (aViewthe various parts of the case) are consistent.

Partialviewcontextimpl in a classic approach, this method abstracts the "processing" out of the way.

public void Processpartial (Phaseid phaseid) {updatefacescontext ();        Partialviewcontext PVC = Ctx.getpartialviewcontext ();        Collection <String> executeids = Pvc.getexecuteids ();        Collection <String> renderids = Pvc.getrenderids ();        Uiviewroot viewroot = Ctx.getviewroot ();            if (Phaseid = = Phaseid.apply_request_values | |            Phaseid = = Phaseid.process_validations | |            Phaseid = = phaseid.update_model_values) {//Skip this processing if "None" are specified in the render list,            Or there were no execute phase client IDs. if (Executeids = = NULL | | executeids.isempty ()) {if (logger.isloggable (Level.fine)) {L  OGGER.log (Level.fine, "No Execute and render identifiers specified.                Skipping component processing. ");            Return } try {processcomponents (viewroot, Phaseid, ExecuteiDS, CTX);                           } catch (Exception e) {if (logger.isloggable (Level.info)) {LOGGER.log (Level.info,                E.tostring (), E); }}//If We have just finished apply_request_values phase, install the//partial respon  Se writer.            We want to make sure this any content//or errors generated in the other phases is written using the            Partial response writer. if (Phaseid = = phaseid.apply_request_values) {Partialresponsewriter writer = pvc.getpartialr                Esponsewriter ();            Ctx.setresponsewriter (writer); }} else if (Phaseid = = Phaseid.render_response) {try {////We RE-ENABL                E response writing.                Partialresponsewriter writer = Pvc.getpartialresponsewriter (); Responsewriter orig = Ctx.getResponsewriter ();                Ctx.getattributes (). Put (Original_writer, orig);                Ctx.setresponsewriter (writer);                Externalcontext Excontext = Ctx.getexternalcontext ();                Excontext.setresponsecontenttype ("Text/xml");                Excontext.addresponseheader ("Cache-control", "No-cache");                Writer.startdocument ();                    if (Isrenderall ()) {Renderall (CTX, viewroot);                    RenderState (CTX);                    Writer.enddocument ();                Return }//Skip This processing if "None" are specified in the Render list,//or there were no ren                Der Phase client IDs. if (Renderids = = NULL | | renderids.isempty ()) {} else {processcomponents (viewroot, PHA                SeId, Renderids, CTX);                } renderstate (CTX);            Writer.enddocument ();  } catch (IOException ex) {              This.cleanupafterview ();                } catch (RuntimeException ex) {This.cleanupafterview ();            Throw the exception throw ex; }        }    }

If the local value is not valid, or if any conversion fails, then the implementation of JSF will add an error message to the Facescontext instance, and then the lifecycle jumps directly to the Render Response The stage page is rendered again and comes with the error message that you just made. Of course, the previously generated error messages placed in the Facescontext will also be displayed.

If any validate method or event listener in the current Facescontext instance calls the Renderresponse method, the JSF implementation jumps to the Render Response stage.

As in the last phase. The Facescontext.responsecomplete method is called if the program needs to redirect to a different Web application resource or generate a response that does not contain a JSF component.

If the current request is defined as a partial request, the local content is returned from the Facescontext , and the local processing method is executed.

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.