简体   繁体   English

什么时候在JSF中确实发生了值转换?

[英]When exactly does the value conversion happen in JSF?

I have consulted several authoritative sources, but either they really contradict each other or I have misunderstood them, or maybe there are more than one conversion taking place? 我咨询了几个权威人士,但是他们是真的互相矛盾,还是我误解了他们,或者说有不止一次转换? Are there differences between the 1.x and 2.x versions of JSF? JSF的1.x和2.x版本之间是否存在差异?

This IBM post states that the conversion happens in the Apply request values phase (Phase 2). IBM帖子声明转换发生在Apply请求值阶段 (阶段2)。

This post by BalusC says here that the default conversion takes place in the Process Validations Phase (Phase 3). BalusC 这篇文章中说,默认转换发生在流程验证阶段 (阶段3)。

The Oracle JEE6 tutorial implies that the conversion takes place in the Update Model Values Phase (Phase 4), saying in the description of this phase: Oracle JEE6教程暗示转换发生在更新模型值阶段 (阶段4),在此阶段的描述中说:

If the local data cannot be converted to the types specified by the bean properties.. 如果本地数据无法转换为bean属性指定的类型。

On the other hand, the graphic illustrating the phases in the same tutorial shows conversion errors emerging from both Process Validations Phase and Update Model Values Phase . 另一方面,说明同一教程中阶段的图形显示了从流程验证阶段更新模型值阶段出现的转换错误。

All of the above posts state that if the immediate attribute is set to true, all conversions and validations are processed in the Apply request phase . 以上所有帖子都指出,如果immediate属性设置为true,则在Apply请求阶段处理所有转换和验证。 This would mean that conversion in that phase is not the default behavior. 这意味着该阶段的转换不是默认行为。

Thank you 谢谢

From UIInput's documentation [emphasis mine]: UIInput的文档 [强调我的]:

During the Apply Request Values phase of the request processing lifecycle, the decoded value of this component, usually but not necessarily a String, must be stored - but not yet converted - using setSubmittedValue(). 在请求处理生命周期的“ 应用请求值”阶段期间,必须使用setSubmittedValue()存储此组件的解码值(通常但不一定是String),但尚未转换 If the component wishes to indicate that no particular value was submitted, it can either do nothing, or set the submitted value to null. 如果组件希望指示没有提交特定值,则它可以不执行任何操作,或将提交的值设置为null。

By default, during the Process Validators phase of the request processing lifecycle, the submitted value will be converted to a typesafe object , and, if validation succeeds, stored as a local value using setValue(). 默认情况下,在请求处理生命周期Process Validators阶段,提交的值将转换为typesafe对象 ,如果验证成功,则使用setValue()存储为本地值。 However, if the immediate property is set to true, this processing will occur instead at the end of the Apply Request Values phase. 但是,如果将immediate属性设置为true,则此处理将在Apply Request Values阶段结束时发生。

During the Render Response phase of the request processing lifecycle, conversion for output occurs as for UIOutput. 在请求处理生命周期的渲染响应阶段,输出转换与UIOutput一样。 There are no differences between JSF 1.x and 2.x versions. JSF 1.x和2.x版本之间没有区别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM