How can I write a custom converter when working with PrimeFaces components that use a list of POJO? My particular problem is with <p:pickList>
<p:pickList converter="????" value="#{bean.projects}" var="project"
itemLabel="#{project.name}" itemValue="#{project}">
Without a converter I get java.lang.ClassCastException because JSF sets the submitted values with unconverted java.lang.String submitted values.
After research on how to write custom converter, here is the solution.
1. create a Java Class that implement
javax.faces.convert.Converter;2. Register your custom converter in
faces-config.xml3. So now inside Primefaces component, u just do
converter="projectConverter". Note thatprojectConverteris the<convert-id>I just created. So to solve my problem above, I do this: