1
I’m a few hours testing and trying to understand why this code here isn’t working and I’m getting one NullPointerExcepetion
. Someone can sense something wrong ?
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.inject.Inject;
import javax.inject.Named;
import modelo.Condomino;
import repositorio.Condominos;
@Named
@RequestScoped
public class CondominoConverter implements Converter{
@Inject
private Condominos condominos;
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if(!value.equals(null)){
Condomino condomino = condominos.getCondominoPorCPF(value);
if (condomino == null)
throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR,"Não existe","Não existe"));
return condomino;
}
return null;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (null == value || !(value instanceof Condomino))
return null;
Condomino condomino = (Condomino) value;
return condomino.getCPF()==null?null:condomino.getCPF().toString();
}
}
where the nullpointer is?
– Henrique Santiago
continued checking and when I use the save this happening two requests should be why I’m getting a nullpointerexcepetion :(
– Denis Benjamim
which line is bursting the
NullPointerException
– Henrique Santiago