Erro ao retornar download para brower

0 respostas
java
D

Amigos estou tentando realizar download de uns arquivos gerados a partir de gráficos gerados
pela aplicação, até ai blz, com o código abaixo tento fazer isso, o que acontece parece que não há retorno
para o download ir para o brower o que pode está errado?

<h:inputHidden id="graficos" value="#{controleSos.chartImageSrcBase64}" />
		<p:remoteCommand name="exportToPdfRemoteCommand" action="#{controleSos.exportPdf}">  
			<p:fileDownload value="#{controleSos.download}"/>
		</p:remoteCommand>`

public void exportPdf(){
	
	String arqSaida = "";


	try {

		String image = getChartImageSrcBase64().split("[,]")[1];

		arqSaida = funcoes.GeradorPDF(image);

		if (arqSaida.contains("")) {
			
			File file = new File(arqSaida);
			//File file = new File("D:\\GESTAO_SOS\\GRAFICO_GESTAOSOS_21071745.zip");
			//int tam = (int) file.length();
			
			InputStream input = new FileInputStream(file);
			ExternalContext ext = FacesContext.getCurrentInstance().getExternalContext();
			setDownload(new DefaultStreamedContent(input, ext.getMimeType(file.getName()), file.getName()));
			
			mensagens.info("PDF Gerado com Sucesso!");
			addLog("PDF DE GRÁFICOS GERADOS COM SUCESSO!", null);
			
			
			return;
		} else { 
			mensagens.info("PDF NÃO FOI GERADO.");
			addLog("PDF NÃO FOI GERADO.", null);
		}
	

	} catch (ErrosException | DocumentException | IOException  e) {
		mensagens.error("ERRO AO GERAR PDF DE GRÁFICOS ");
		addLog("ERRO AO GERAR PDF DE GRÁFICOS. ", e);
		e.printStackTrace();
	} 
}
Criado 21 de junho de 2016
Respostas 0
Participantes 1