JSF生命周期-验证失败后呈现响应 [英] Jsf life cycle - render response after validation failure

查看:104
本文介绍了JSF生命周期-验证失败后呈现响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望BalusC或您中的一位JSF专家能够帮助我理解JSF生命周期的各个方面,尤其是渲染.

I'm hoping BalusC or one of you JSF experts can help me understand the finer points of the JSF life cycle, particularly rendering.

我要努力理解的是,在渲染响应期间,将从模型中获取值并显示给用户.现在,如果存在验证错误,则不会更新模型,因此渲染器必须必须向用户显示组件树中的无效值.一切都很好,但是渲染器如何确定是从模型中读取还是从组件树中读取?如果来自组件树,这是否意味着如果请求通过验证并且事件处理程序在呈现之前更新模型值,这些值会反映给用户吗?

What I'm struggling to understand is that during render response, values are obtained from the model and displayed to the user. Now, if there were validation errors, the model is not updated, so the renderer must have to show the user the invalid value from the component tree. That's all well and good but how does the renderer determine whether to read from the model, or read from the component tree? If it's from the component tree, does that mean if a request passes validation and an event handler updates model values just prior to rendering, will those values be reflected to the user?

我已经阅读了很多有关jsf生命周期的信息,但是我发现其中没有什么内容足以回答我的问题.我想确切地了解这些东西是如何工作的.

I've read lots about the jsf life cycle but nothing I've found goes into it deeply enough to answer my questions. I want to understand precisely how this stuff works.

推荐答案

在应用请求值阶段,所有请求参数均由setSubmittedValue()设置为UIInput上的提交值.

During the apply request values phase, all request parameters are set as submitted value on UIInput by setSubmittedValue().

在验证阶段,仅且仅当该值有效时,才将提交的值设置为null,并将已转换和验证的值由setValue()设置在UIInput上.因此,如果该值无效,则提交的值将不会设置为null.

During the validations phase, only and only if the value is valid, the submitted value is set to null and the converted and validated value is set on UIInput by setValue(). So if the value is not valid, then the submitted value won't be set to null.

在更新模型值阶段,将使用该值更新模型值.

During the update model values phase, the model value is updated with that value.

在渲染响应阶段,UIInput渲染器首先检查getSubmittedValue()是否不返回null.如果没有(因此,验证失败),则显示它.否则,只需显示模型值即可.

During the render response phase, the UIInput renderer first checks if getSubmittedValue() doesn't return null. If it doesn't (so, validation has failed), then display it. Otherwise just display the model value.

这篇关于JSF生命周期-验证失败后呈现响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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