验证期间UIInput#getValue()和getLocalValue()之间的区别 [英] Difference between UIInput#getValue() and getLocalValue() during validation

查看:136
本文介绍了验证期间UIInput#getValue()和getLocalValue()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对 jsf一次验证两个字段.

如果字段已经过验证,则使用此方法有什么区别? ValueHolder API文档不是回答这个问题非常有帮助.

解决方案

如果UIInput组件已预先验证并标记为无效(即isValid()方法返回false),则getLocalValue()返回null,但getValue()返回旧模型值(如果有).如果标记为有效,则两者都返回相同的值,即已提交,已转换和已验证的值.

您想预先在isValid()上添加支票.您可能会发现 OmniFaces 多个字段验证器的源代码示例很有帮助.参见 源代码链接,位于 <o:validateEqual> 展示页面的底部. /p>

另请参见:

I would like to have an illustrative explanation about the difference between getValue() and getLocalValue() methods of UIInput components in the aspect of performing multiple field validation: jsf validate two fields in one time.

What is the difference in usage of this methods if the fields are already validated? The ValueHolder API documentation is not very helpful in answering this.

解决方案

If the UIInput component has been validated beforehand and is marked invalid (i.e. isValid() method returns false), then the getLocalValue() returns null, but the getValue() returns the old model value, if any. If it's marked valid, then both returns the same value, namely the submitted, converted and validated value.

You'd like to add a check on isValid() beforehand. You may find the source code examples of the OmniFaces multiple field validators helpful. See the ValidateMultipleFields source code link at the bottom of the <o:validateEqual> showcase page.

See also:

这篇关于验证期间UIInput#getValue()和getLocalValue()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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