isValidationFailed默认值 [英] isValidationFailed default value
问题描述
如果验证失败,则在渲染响应阶段之后,方法facesContext.isValidationFailed()
将返回什么?在这种情况下,它将为我返回false
.
What would the method facesContext.isValidationFailed()
return after the Render Response Phase when the validation fails? It returns false
for me in this case.
推荐答案
It will only return true
when FacesContext#validationFailed()
has been called by the JSF validation internals or by your own code as follows:
FacesContext.getCurrentInstance().validationFailed();
As far JSF internal code is concerned, only UIInput#processValidators()
and UIViewParameter#processValidators()
will implicitly call this method whenever a ValidatorException
has been caught.
如果它为您返回false
,那么您显然正在以非标准方式进行验证.例如,在操作方法内部,当您应该使用真实的 Validator
.
If it returns false
for you, then you're apparently doing validation in a non-standard way. For example inside the action method, while you should be using a real Validator
for this.
这篇关于isValidationFailed默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!