java - JSF 中的值转换究竟发生在什么时候?

标签 java jsf jakarta-ee jsf-2 java-ee-6

我查阅了几个权威资料,但要么他们真的相互矛盾,要么我误解了他们,或者可能有不止一个转换发生? JSF 的 1.x 和 2.x 版本之间有区别吗?

IBM post表示转换发生在应用请求值阶段(第 2 阶段)。

post by BalusChere默认转换发生在流程验证阶段(第 3 阶段)。

Oracle JEE6 tutorial暗示转换发生在更新模型值阶段(阶段 4),在该阶段的描述中说:

If the local data cannot be converted to the types specified by the bean properties..

另一方面,说明同一教程中各个阶段的图形显示了流程验证阶段更新模型值阶段出现的转换错误。

以上所有帖子都指出,如果 immediate 属性设置为 true,则所有转换和验证都在 Apply 请求阶段 中处理。这意味着该阶段的转化不是默认行为。

谢谢

最佳答案

来自 UIInput's documentation [强调我的]:

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(). If the component wishes to indicate that no particular value was submitted, it can either do nothing, or set the submitted value to 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(). However, if the immediate property is set to true, this processing will occur instead at the end of the Apply Request Values phase.

During the Render Response phase of the request processing lifecycle, conversion for output occurs as for UIOutput. There are no differences between JSF 1.x and 2.x versions.

关于java - JSF 中的值转换究竟发生在什么时候?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12836955/

相关文章:

java - Eclipse - EJB 项目 - 提取包含接口(interface)的 Jar

java - JAR 文件中的 jaxb.properties

jakarta-ee - 焊缝双射和焊接

java - MethodHandles.filterArguments() 示例给出了异常

java - 按下目标为 'frozen' 的 commandLink 后,Chrome 中的页面变为 ="_blank"

java - 寻找有关 Java 单元测试的好信息

html - JSF 读取托管 bean 中的动态输入元素

html - 当我在过滤器中使用 requestdispatcher 重定向页面时,CSS 内容未应用于页面

java - tomcat 将模块 war 部署到子 url 路径

java - 第三级倒逗号(没有得到正确的标题)