问题描述
我有一个selectMenu,在处理程序中定义的(SelectItems)列表如下
I have a selectMenu, with list of (SelectItems) defined in handler as follows
Handler { List(SelectItem) stateList; State state; }
State { String stateCd; }
JSF代码::
<h:selectOneMenu value="#{state.stateCode}">
<f:selectItems value="#{handler.stateList}">
</h:selectOneMenu>
现在我的列表在requestScope中,并且我看到提交的值是字符串并且存在于列表中,但是我仍然收到验证错误:值无效".有人可以提供帮助.
Now my list is in requestScope, and I see submitted value is string and is present in the list but I still get "Validation error: Value is not valid".Can someone assist.
推荐答案
这意味着所选项目与列表中可用的任何项目都不匹配.也就是说,stateCode.equals(stateList.get(i))
从未针对任何项目返回true
.
This means that the selected item does not match any of the items available in the list. I.e., the stateCode.equals(stateList.get(i))
has never returned true
for any of the items.
当在验证阶段stateList
为空或没有(正确)实现值类型的equals()
方法时,会发生这种情况.
This can happen when the stateList
is empty during validations phase, or when the equals()
method of the value type is not (properly) implemented.
这篇关于Jsf:验证错误值对于SelectOneMenu无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!