I\'m trying to apply a JSF converter to an Entity inside a selectOneMenu, but the converter is not recognized, I get this warning in my xhtml file,
<<\
itemLabel="#{projet.nomProjet}": Property 'nomProjet' not found on type java.lang.String
This error message tells that #{projet}
is during runtime actually a java.lang.String
. Let's look where's #{projet}
is coming from.
<f:selectItems value="#{affectation.projetsAffectablesCollaborateur()}"
var="projet" itemValue="#{projet}" itemLabel="#{projet.nomProjet}" />
Thus, #{affectation.projetsAffectablesCollaborateur()}
actually returned a List<String>
. If this is unexpected, then beware of generic type erasure and doublecheck all unchecked casts that the generic type is not incorrectly assumed. Generally, the mistake is in the persitence layer. For example, when you mistakenly execute the query SELECT p.nomProject FROM Project p
instead of SELECT p FROM Project p
and then performed an unchecked cast against List<Projet>
instead of List<String>
.
Do note that rendering item labels doesn't involve the converter at all, so showing and blaming it is unnecessary. The converter is only used on item values.