[RESOLVIDO] Problema na abertura de relatório montado no iReport

2 respostas
C

Boa noite pessoal.

Montei um relatório no iReport. Compilei e exibi no iReport mas quando tento abrir na aplicação recebo a seguinte mensagem de erro:

GRAVE: Error Rendering View[/restrito/setor.xhtml]
javax.el.PropertyNotFoundException: /restrito/setor_relatorio.xhtml @18,51 value="#{setorBean.nomeSetor}": The class 'gestao.web.SetorBean' does not have the property 'nomeSetor'.
...
..
.
Na minha classe setorBean tenho os seguintes métodos:
public StreamedContent getArquivoRetorno() {
	FacesContext context = FacesContext.getCurrentInstance();
	ContextoBean contextoBean = ContextoUtil.getContextoBean();
	String usuario = contextoBean.getUsuarioLogado().getLogin();
	String nomeRelatorioJasper = "setor";
	String nomeRelatorioSaida = usuario + "_setor";
	RelatorioUtil relatorioUtil = new RelatorioUtil();
	HashMap parametrosRelatorio = new HashMap();
	parametrosRelatorio.put("nomeSetor", this.setor.getNome());
	try {
		this.arquivoRetorno = relatorioUtil.geraRelatorio(parametrosRelatorio, nomeRelatorioJasper, nomeRelatorioSaida, this.tipoRelatorio);
	} catch (UtilException e) {
		context.addMessage(null, new FacesMessage(e.getMessage()));
		return null;
	}
	return this.arquivoRetorno;
}

public void setArquivoRetorno(StreamedContent arquivoRetorno) {
	this.arquivoRetorno = arquivoRetorno;
}

public int getTipoRelatorio() {
	return tipoRelatorio;
}

public void setTipoRelatorio(int tipoRelatorio) {
	this.tipoRelatorio = tipoRelatorio;
}
E meu filtro que está no HTML está assim:
<h:form id="relatorio">
	<h:panelGroup>
		<fieldset>
		<legend>
			Parâmetros do Relatório
		</legend></fieldset>
		<h:panelGrid columns="3">
			<h:outputLabel value="Setor" />
			<h:inputText value="#{setorBean.nomeSetor}" />
			<p:commandButton value="Imprimir" ajax="false">
				<p:fileDownload value="#{setorBean.arquivoRetorno}" />
			</p:commandButton>
		</h:panelGrid>
	</h:panelGroup>
</h:form>

Alguém pode me dar uma dica do que fiz errado?

2 Respostas

WRYEL

a exceção está clara:

javax.el.PropertyNotFoundException: /restrito/setor_relatorio.xhtml @18,51 value="#{setorBean.nomeSetor}": The class 'gestao.web.SetorBean' does not have the property 'nomeSetor'.

sua classe “SetorBean” não tem um atributo chamado “nomeSetor”. Se houver, ele precisa de metodos get/set para que o JSF possa acessa-los.

[]'s

edit:

pelo seu codigo:

parametrosRelatorio.put("nomeSetor", this.setor.getNome());

acho que no seu xhtml deve ser:

<h:inputText value="#{setorBean.setor.nome}" /> ao invés de <h:inputText value="#{setorBean.nomeSetor}" />

[]'s

C

Paff. Que furada.
Obrigado pela dica.

Criado 18 de novembro de 2011
Ultima resposta 18 de nov. de 2011
Respostas 2
Participantes 2