1
I am retrieving my object from the datatable more at the time I redirect the datatable to another page to make a change, it shows an error. More takes the Object ID, I made a convert more unsuccessfully.
my Converter
package converter;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.inject.Inject;
import dao.FabricanteDAO;
import modelo.Fabricante;
@FacesConverter(forClass = Fabricante.class)
public class FabricanteConverter implements Converter {
@Inject
private FabricanteDAO dao;
public Object getAsObject(FacesContext arg0, UIComponent arg1, String value) {
Fabricante fabricante = null;
if (value != null) {
fabricante = this.dao.buscarPeloCodigo(new Long(value));
}
return fabricante;
}
public String getAsString(FacesContext arg0, UIComponent arg1, Object valor) {
if (valor != null) {
Fabricante fabricante = (Fabricante) valor;
return fabricante.getCodigo() == null ? null : fabricante.getCodigo().toString();
}
return "";
}
}
There is Alura’s own forum, which may help you more quickly. Have you tried to post there?
– Murillo Goulart