0

I have read many posts about this JSF2 validation error, but cannot see why this is occurring. My select items are a List where ListItem is a POJO with two String fields, key, and value. When I submit the page choosing a select item option with a value of "0", I get the following error: Validation Error: Value is not valid.

The value to be submitted is bound to an int. Here is the equals method in ListItem, but I have a debug point on this method and it doesn't appear to get hit, so I can't see if this is the issue:

public boolean equals(Object other)
{
    if (other == null || !(other instanceof ListItem))
        return false;
    ListItem otherLI = (ListItem) other;
    return otherLI.key.equals(key);
}

Any ideas?

4

1 回答 1

0

在 UISelectOne validateValue 方法中进行一些调试后似乎已修复它,当提交的值为 0 作为 Integer 对象时,SelectUtils.valueIsNoSelectionOption 似乎返回 true。

我的 noSelectionOption 如下:

<f:selectItem noSelectionOption="true" itemLabel="Please Select" itemValue="" />

将 itemValue 更改为 #{null} 后,它似乎工作正常。

<f:selectItem noSelectionOption="true" itemLabel="Please Select" itemValue="#{null}" />
于 2013-07-25T09:23:50.863 回答