The convert doesn't work. This is the code abount my xhtml(For now I need to list only all values):
<p:selectCheckboxMenu id="autoriRicerca"
value="#{ricercaLibroBean.autoriRicerca}"
converter="autoriConverter"
multiple="true" filter="true" filterMatchMode="startsWith"
panelStyle="width:250px">
This is my Converter:
@FacesConverter("autoriConverter")
public class AutoriCoverter implements Converter {
@Inject
private AutoriDAO userService;
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
if (submittedValue == null || submittedValue.isEmpty()) {
return null;
}
try {
return userService.getListaAutori();//return the lis about authors
} catch (NumberFormatException e) {
throw new ConverterException(new FacesMessage(String.format("%s is not a valid User ID", submittedValue)), e);
}
}
public String getAsString(FacesContext context, UIComponent component, Object object) {
if (object == null) {
return "";
}
if (object instanceof Autori) {
Autori autore = (Autori) object;
String nomeAutore = autore.getNomeAutore();
return nomeAutore;
} else {
throw new ConverterException(new FacesMessage(object + " is not a valid car"));
}
}
}
in my bean I have:
private List<Autori> autoriRicerca; // and get and set method
the class Autori
has a (id,nameAuthor).
I don't know which is the problem. It seems like the code doesn't enter in the converter method. I have put some breackpoints and they doesn't execute in debug. Anyone an help me?