JSF Tutorial (10)-Lifecycle update Model Values Phase

Source: Internet
Author: User
Tags throwable

during the entire JSF life cycle, the stage of value, validation, and finalRequestTo get a reasonable value, the following is the assignment of the corresponding service-side object (Managebean) at this stage. JSFimplementation is just going to update andinputin the componentvalueproperty corresponds to theBeanthe value of the property, that is, if there is no Managebean attribute "bound" to the input class's component in the interface then the Bean's properties are not updated. It is necessary to note that if the local data cannot be converted to the corresponding BEANattribute type, the life cycle is directly anchored to theRender Responsestep, this time the page will display an error message (It is good to understand that you want to pass a value to a bean so at least there should be a set method in this bean, but if the parameters in the set method are inconsistent with the arguments passed, it will be an error), The above procedure is similar to the error generated during validation.


The following scenarios are basically the same as those in the previous two steps, except that the following is happening in the Update Model phase.

If any of the Updatemodels methods or listeners call the Renderresponse method on the current Facescontext instance, theJSF creator jumps to Render Response stage.

In line with the above steps, relocating to an external resource or generating a response that does not contain a JSF component will call the Facescontext.responsecomplete method.

If any events are added to the queue at this stage, theJSF implementation will transfer them to the relevant listener.

Similar to the above two phases, if the current request is a local request, then the local context will be restored according to the contents of the Facescontext , and the local processing method will be called.

Here to see a uiinput code, the previous several posts mentioned in the various stages of the process, is performed by the process* method in the Partialviewcontextimpl class, But in the end, the people who actually do the bottom job are only the bottom. Here is one of the component classes. With the update model stage as an example, the front is all ready to update the bottom-level method to update the value of the model (decision-makers are responsible for decisions, work is always a soldier), the code is as follows

public void Updatemodel (Facescontext context) {if (context = = null) {throw new NullPointerException ();        } if (!isvalid () | |!islocalvalueset ()) {return;        } valueexpression ve = getvalueexpression ("value");            if (ve! = null) {Throwable caught = null;            Facesmessage message = NULL;                try {ve.setvalue (Context.getelcontext (), Getlocalvalue ());                SetValue (NULL);            Setlocalvalueset (FALSE);                } catch (Elexception e) {caught = e;                String messagestr = E.getmessage ();                Throwable result = E.getcause ();                    while (null! = result && Result.getclass (). IsAssignableFrom (Elexception.class)) {                    Messagestr = Result.getmessage ();                result = Result.getcause ();    } if (null = = MESSAGESTR) {message =                     Messagefactory.getmessage (context, update_message_id, Messagefactory.get                Label (context, this));                                               } else {message = new Facesmessage (Facesmessage.severity_error,                Messagestr, MESSAGESTR);            } setvalid (FALSE);                } catch (Exception e) {caught = e; Message = Messagefactory.getmessage (context, update_message_id, Messagefactor                Y.getlabel (context, this));            Setvalid (FALSE);                } if (caught! = null) {ASSERT (Message! = NULL);                PENDING (edburns): Verify this was in the spec.   @SuppressWarnings ({"Throwableinstanceneverthrown"}) updatemodelexception Toqueue =                   New Updatemodelexception (message, caught);                                                Exceptionqueuedeventcontext eventcontext = new Exceptionqueuedeventcontext (context,                                                Toqueue, this,                Phaseid.update_model_values); Context.getapplication (). Publishevent (Context, exceptionqueuedevent.c                            Lass, Eventcontext); }                    }    }

The final end still fell to El-ri-1.0.jar This bag , then go down is jsp-api-2.1.jar This package , thus can prove that JSF is in JSP on the basis of (good nonsense wow ~), to believe that look at the above figure is a lot of people understand. But if I had taken out this picture at first, I believed most people just glanced at it (at least I glanced at it and found the picture to be really good). Learning is a process that needs to be repeated, chewing more and more.

Related Article

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.