0
我得到验证错误:值不是有效的错误。我已经发现问题是等于方法。所选对象被正确地作为参数传递,但由于某种原因,与之比较的实体是错误的。h:selectOneListBox验证错误:值无效
<div class="col-sm-8">
<h:selectOneListbox id="${cc.attrs.id}_test" converter="#{cc.attrs.converter}"
size="#{cc.attrs.selector.selectedList.size()+1}" style="height: 150px"
value="#{cc.attrs.selector.removeItem}" styleClass="form-control">
<f:selectItems value="#{cc.attrs.selector.selectedList}" var="test"
itemValue="#{test}"
itemLabel="#{test.displayName}" />
<f:ajax event="change" render="${cc.attrs.id}_jts_panel ${cc.attrs.id}_legend" />
</h:selectOneListbox>
</div>
这里是equals方法:
@Override
public boolean equals(Object object)
{
if (!(object instanceof ObjectTest))
{
return false;
}
ObjectTest other = (ObjectTest) object;
if (this.attribute1 == null || this.attribute2 == null) {
return false;
}
if (other.attribute1 == null || other.attribute2 == null) {
return false;
}
if ((this.attribute1.getName() == null && other.attribute1.getName() != null) || (this.attribute1.getName() != null && !this.attribute1.getName().equals(other.attribute1.getName())))
{
return false;
}
if ((this.attribute2.getName() == null && other.attribute2.getName() != null) || (this.attribute2.getName() != null && !this.attribute2.getName().equals(other.attribute2.getName())))
{
return false;
}
return true;
}
现在出于某种原因,this.attribute1.getName()比other.attribute1.getName不同()。传递给equals方法的对象是正确的,但实体本身与传递的对象不同。由于这是一个等值方法所在的实体类,所以this.attribute的值如何被拾取?难道我做错了什么?
没有太多的理解您的问题,我的猜测是你的转换器导致你的问题:'转换器=“#{cc.attrs.converter}”'这是什么评估? –
你是对的Jorge。你可以在下面添加你的答案作为答案,所以我可以接受它作为正确的答案吗?谢谢你。 –
完成它。没有太多解释只是添加评论作为你问的答案。很高兴它帮助你。 :) –