应用请求值和更新模型值之间的差异 [英] Difference between Apply Request Values and Update Model Values

查看:94
本文介绍了应用请求值和更新模型值之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常对这两个阶段感到怀疑.以下是我的理解:

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

  1. 应用请求值

  • 在此阶段,提交的值来自request参数.然后将请求值设置到支持bean中,即设置为组件UIInput

更新模型值

  • 在此阶段,已处理的值从备用Bean(UIInput)传输到托管Bean. (这是我们自定义的JSF Bean).

我认为我的理解是正确的.但是,读很少的文章使我感到困惑.我想让我在这两个阶段更加清晰.请澄清一下.

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.

推荐答案

应用请求值

  • 在此阶段,提交的值来自request参数.然后将请求值设置到支持bean中,即设置为组件UIInput

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

那不是完全正确的.这些值未设置到支持Bean中.它们被设置为组件.基本上,组件树中的每个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()));

此处input UIInput request HttpServletRequest .

Here input is UIInput and request is HttpServletRequest.

更新模型值

  • 在此阶段,已处理的值从备用Bean(UIInput)传输到托管Bean. (这是我们自定义的JSF Bean).

Update Model Values

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

也不完全正确. UIInput组件不支持bean.基本上,组件树中的每个UIInput组件都会发生以下情况:

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());

此处,bean和属性基于输入的值绑定,例如value="#{bean.property}".

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

总而言之,您的困惑显然​​是在区分JSF组件树,JSF支持bean和JSF管理bean. JSF组件树是您在JSP/Facelets页面中定义的树,您可以通过

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.

这篇关于应用请求值和更新模型值之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆