2
I am trying to inject a Managed Property in my class, but whenever I try to access it in a method annotated with @PostConstruct
it returns me null thus generating an Exception.
Follow down my class:
package br.com.pathfind.importacao.managedbean;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import br.com.lantech.pathfind.corporativo.service.ParametroService;
import br.com.lantech.pathfind.model.Parametro;
import br.com.lantech.pathfind.model.exception.PathfindException;
@ManagedBean(name = "importarArquivoBean")
@ViewScoped
public class ImportarArquivoBean implements Serializable {
private static final long serialVersionUID = 1L;
private Parametro parametroERP;
@ManagedProperty("#{parametroService}")
private ParametroService parametroService;
private boolean promax;
@PostConstruct
private void inicializar() {
//parametroService retornando nulo.
try {
parametroERP = parametroService.recuperaPorDescricao("ERP");
} catch (PathfindException e) {
e.printStackTrace();
}
promax = false;
if (parametroERP.getValor().equalsIgnoreCase("PROMAX")) {
promax = true;
}
}
public boolean deveExibirSAP() {
return getParametroERP().getValor().equalsIgnoreCase("SAP");
}
public Parametro getParametroERP() {
return parametroERP;
}
public void setParametroERP(Parametro parametroERP) {
this.parametroERP = parametroERP;
}
public ParametroService getParametroService() {
return parametroService;
}
public void setParametroService(ParametroService parametroService) {
this.parametroService = parametroService;
}
public boolean isPromax() {
return promax;
}
public void setPromax(boolean promax) {
this.promax = promax;
}
}
Does anyone have any idea what it might be? Grateful
Would you be so kind as to post the code of the Parametroservice class?
– Bonifacio