Adverts
I am sure that this one will catch you out at some point when using Java Server Faces. The error message is cryptic in the extreme. The JSF frame work allows you to use a map, amongst other things, to populate an f:selectItems tag with selectable items. If the object you are trying to recover the map from is null or the property is null you get this error message:
java.lang.IllegalArgumentException:
Conversion Error setting value ''{0}'' for ''{1}''.
com.sun.faces.util.Util.getSelectItems(Util.java:628)
com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber
(MenuRenderer.java:488)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect
(MenuRenderer.java:465)
com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd
(MenuRenderer.java:430)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:720)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive
(HtmlBasicRenderer.java:443)
com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren
(GridRenderer.java:233)
...more...
As you can see the error doesn't tell you that it was unable to get any values it seems to indicate that there was a problem converting them.
I found, to my cost, there is an alternative reason for this error message. If there is a mistake in the value binding such that it is interpreted as a String literal rather than a value binding this is the result. For instance if you entered #{days.dayItems) rather than #{days.dayItems} (note the first one is closed with a bracket not a brace). I wish the framework had a warning mechanism that would warn you about this. I mean how often do you use f:selectItems with a literal rather than a value binding?