{"id":1440,"date":"2011-07-27T09:05:23","date_gmt":"2011-07-27T09:05:23","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=1440"},"modified":"2011-07-27T09:07:44","modified_gmt":"2011-07-27T09:07:44","slug":"fselectitem-error-java-lang-string-cannot-be-cast-to-javax-faces-model-selectitem","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=1440","title":{"rendered":"f:selectItem error &#8211; java.lang.String cannot be cast to javax.faces.model.SelectItem"},"content":{"rendered":"<p>I received this error when using &lt;<em>f: selectItem<\/em>&gt; on a prototype of a page:-<\/p>\n<p style=\"padding-left: 30px;\"><em>java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.model.SelectItem<\/em><\/p>\n<p>It turns out that the error was trivial, but easy to miss at first glance.<\/p>\n<p>My initial code was as follows:-<\/p>\n<p style=\"padding-left: 30px;\"><em>&lt;f:selectItem value=&#8221;1&#8243; itemLabel=&#8221;&amp;lt;default&amp;gt;&#8221;\/&gt;<\/em><\/p>\n<p>The mistake was to use the <em>value <\/em>attribute instead of the <em>itemValue<\/em>\u00a0 attribute. The following is the corrected code:-<\/p>\n<p style=\"padding-left: 30px;\"><em>&lt;f:selectItem itemValue=&#8221;1&#8243; itemLabel=&#8221;&amp;lt;default&amp;gt;&#8221;\/&gt;<\/em><\/p>\n<p>\u00a0This solves the problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I received this error when using &lt;f: selectItem&gt; 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:- &lt;f:selectItem value=&#8221;1&#8243; itemLabel=&#8221;&amp;lt;default&amp;gt;&#8221;\/&gt; The mistake was to use the value attribute instead of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[40,184,16],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1440"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1440"}],"version-history":[{"count":3,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1440\/revisions"}],"predecessor-version":[{"id":1443,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1440\/revisions\/1443"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}