I have a problem implementing a custom converter...
my xhtml is:
...
<span class="cien">
<h:outputLabel value="Director de Area Correspondiente:"
styleClass="negritas" />
<h:selectOneMenu value="#{ordenBO.director}" id="director-area"
converter="superiorAuditoriaConverter"
converterMessage="Error al seleccionar el Director">
<f:selectItems value="#{ordenBO.directores}"></f:selectItems>
</h:selectOneMenu>
<p:message for="director-area"></p:message>
</span>
...
this is how I fill my h:SelectOneMenu:
...
this.directores = new ArrayList<SelectItem>();
for (SuperiorAuditoriaDTO sup: daoSuperiorAuditoria.getDirectoresASM())
this.directores.add(new SelectItem(sup, sup.getProfesion() + " " +
sup.getNombre_completo()));
...
this is my Custom converter:
....
@FacesConverter(forClass = SuperiorAuditoriaDTO.class, value =
"superiorAuditoriaConverter")
public class SuperiorAuditoriaConverter implements Converter {
private static SuperiorAuditoriaDAO dao = new SuperiorAuditoriaDAO();
public Object getAsObject(FacesContext arg0, UIComponent arg1, String id_persona) {
SuperiorAuditoriaDTO s = null;
try {
s = dao.getSuperiorASM(Integer.parseInt(id_persona));
} catch(Exception e) {
e.printStackTrace();
}
return s;
}
public String getAsString(FacesContext arg0, UIComponent arg1, Object auditor) {
return String.valueOf(((SuperiorAuditoriaDTO) auditor).getId_persona());
}
}
Can somebody help me?? I always got an error message saying that the value that I try to convert is not valid..
I'm using jsf 2 mojarra... and I also have equals and hashCode method implemented...
thanks..