Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Apply Request Values and Update Model Values

Tags:

jsf

lifecycle

I often get doubt on these two phases. The following is my understanding:

  1. Apply Request Values

    • In this phase, the submitted values are coming from the request parameter. Then the request values are set into the backing bean ie.setting to components UIInput
  2. Update Model Values

    • In this phase, processed values are transferred from backing bean (UIInput) to managed beans. (It is our custom defined JSF beans).

I am thinking that my understanding is correct. But, reading few articles made me confused. I want to make me more clear on these two phases. Please clarify me.

like image 423
Krishna Avatar asked Jan 20 '11 16:01

Krishna


1 Answers

Apply Request Values

  • In this phase, the submitted values are coming from the request parameter. Then the request values are set into the backing bean ie.setting to components UIInput

That's not entirely correct. The values are not set into backing beans. They are set into components. Basically the following happens for each UIInput component in the component tree:

input.setSubmittedValue(request.getParameter(input.getClientId()));

Here input is UIInput and request is HttpServletRequest.


Update Model Values

  • In this phase, processed values are transferred from backing bean (UIInput) to managed beans. (It is our custom defined JSF beans).

Also not entirely correct. UIInput components are not backing beans. Basically the following happens for each UIInput component in the component tree:

bean.setProperty(input.getValue());

Here, the bean and property is based on the input's valuebinding, e.g. value="#{bean.property}".


All with all, your confusion is clearly in distinguishing between the JSF component tree, the JSF backing beans and the JSF managed beans. The JSF component tree is the one which you've definied in the JSP/Facelets page and as you can obtain by FacesContext#getViewRoot(). The JSF backing beans are Javabean classes whose properties are bound to the component tree using EL such as #{bean.property}. The JSF managed beans are concrete instances of those Javabean classes. They can be request, session or application scoped (and in JSF 2.0 also view scoped). It are the managed beans where the values are actually been set and retrieved.

See also

  • Debug JSF lifecycle
like image 92
BalusC Avatar answered Oct 23 '22 03:10

BalusC