July 27th, 2011
9:05 am
Posted under JSF
Permalink
Tags Gotcha, JSF, Tip
I received this error when using <f: selectItem> on a prototype of a page:-
java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.model.SelectItem
It turns out that the error was trivial, but easy to miss at first glance.
My initial code was as follows:-
<f:selectItem value=”1″ itemLabel=”<default>”/>
The mistake was to use the value attribute instead of the itemValue attribute. The following is the corrected code:-
<f:selectItem itemValue=”1″ itemLabel=”<default>”/>
This solves the problem.
Leave a Reply
You must be logged in to post a comment.