I am getting a Validation Error: Value is not valid error. I have identified the problem to be the equals method. The object selected gets passed correctly as an argument, but for some reason, the entity that is compared with is wrong.
<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>
Here is the equals method:
@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;
}
Now for some reason, this.attribute1.getName() is different than other.attribute1.getName(). The object passed into the equals method is the correct one, but the entity itself is a different one than the object passed. How is the value of this.attribute being picked up since this is an entity class where the equals method is at? Am I doing something wrong?