Jsf: validation error value invalid for SelectOneMenu

I have selectMenu, with a list (SelectItems) defined in a handler, as follows

Handler { List(SelectItem) stateList; State state; } State { String stateCd; } 

JSF Code ::

 <h:selectOneMenu value="#{state.stateCode}"> <f:selectItems value="#{handler.stateList}"> </h:selectOneMenu> 

Now my list is in the Scope request, and I see that the value represented is a string and is present in the list, but I still get "Validation error: value is invalid". Help someone help.

+7
source share
1 answer

Validation error: value is invalid

This means that the selected item does not match any of the items available in the list. Ie, stateCode.equals(stateList.get(i)) never returned true for any of the elements.

This can happen when stateList empty during the validation phase or when the equals() method of value type is not implemented (correctly).

See also:

+32
source

All Articles