Validation Error: Value is not valid

后端 未结 3 808
轮回少年
轮回少年 2020-11-21 04:22

I have a problem with a p:selectOneMenu, no matter what I do I cannot get JSF to call the setter on the JPA entity. JSF validation fails with this message:

3条回答
  •  甜味超标
    2020-11-21 04:47

    This can be a Converter Issue or else DTO issue. Try to solve this, by adding hashCode() and equals() methods in your object DTO; In the above scenario you can generate these methods within the Location object class which indicate as the 'DTO' here.

    Example:

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (id ^ (id >>> 32));
        return result;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Location other = (Location) obj;
        if (id != other.id)
            return false;
        return true;
    }
    
    • Please note that the above example is for an 'id' of type 'long'.

提交回复
热议问题