JSF Validation Error While Using Custom Converter

前端 未结 1 1232
南旧
南旧 2020-12-18 14:03

I am setting up a form using JSF (I\'m pretty new at this) and I am getting a Validation Error: Value is not valid message on one of the fields. This field is

1条回答
  •  隐瞒了意图╮
    2020-12-18 14:26

    Validation Error: Value is not valid

    In case of , you will get this when error whenever the selected item does not match any of the items available in the list. I.e. selectedItem.equals(selectItem) has never returned true for any of the items.

    Since it's apparently a custom object (the Status class), did you implement its Object#equals() (and #hashCode()) properly? You can if necessary let the IDE (Eclipse/Netbeans) autogenerate them.

    See also:

    • Overriding equals and hashCode in Java
    • How to implement equals() in beans/entities

    Update: after having a closer look at your code, it turns out that you're actually submitting #{s.id} instead of #{s} (the whole Status object). Fix the itemValue accordingly and it should work (if equals() is still doing its job properly).

    0 讨论(0)
提交回复
热议问题