Download with primefaces 5.3 after 5.1 migration does not work

3

I'm migrating from primeface 5.1 to 5.3. It was meant to be simple, just change the version in maven.

But it's not quite right

The p: fileDownload command no longer works

<p:commandButton id="exportarArquivo" icon="ui-icon-print" value="Exportar arquivo" disabled="#{comissaoCobradorMB.isParametros()}" process="@this" > 
    <p:fileDownload value="#{comissaoCobradorMB.file}" />
</p:commandButton>

Debugging the following error appears in browse (chrome).

Request return with error: parsererror. primefaces.js.xhrml: 1

Below MB

The code is a bit old but it worked.

Note that a report is generated. I checked and the same is generated.

public StreamedContent getFile() {
        geraRelatorio();
        return this.file;
    }


    private void geraRelatorio() {
        String path ;
        String nome ;
        String extensao;
        String pathReal ;
        String pathNome ;

        DateTimeFormatter fDataParaString = DateTimeFormatter.ofPattern("yyyyMMdd");
        DateTimeFormatter fDataParaStringData = DateTimeFormatter.ofPattern("dd/MM/yyyy");

        Map parametros = new LinkedHashMap();
        parametros.put("Data De" , fDataParaStringData.format(getDataInicial()));       //fDataParaString.format(this.getDataDe()) ) ;  
        parametros.put("Data Ate", fDataParaStringData.format(getDataFinal()));         // fDataParaString.format(this.getDataDe()) );

        extensao = "."+this.getTipoArquivo();
        path = "/WEB-INF/temporarios";
        nome = "comissaoCob";
        nome+="_De_"+fDataParaString.format(this.getDataInicial());
        nome+="_Ate_"+fDataParaString.format(this.getDataFinal());
        nome+="_Gr_";

        FacesContext facesContext = FacesContext.getCurrentInstance();  
        ServletContext servletContext = (ServletContext)facesContext.getExternalContext().getContext();
        pathReal  = servletContext.getRealPath(path);

        nome = Texto.nomePadrao(pathReal, nome, extensao);

        GeraArquivoTipo geraArquivoTipo;
        if(this.getTipoArquivo().trim().equals("PDF")){
            System.out.println(".............Entrou no PDF");
            geraArquivoTipo = GeraArquivoTipo.PDF;
        } else {
            geraArquivoTipo = GeraArquivoTipo.EXCEL;
            System.out.println(".............Entrou no Excel");
        }

        new RelatorioDeComissaoDeCobradores(comissao,pathReal.trim()+"/"+nome, parametros, geraArquivoTipo);

        pathNome = path+"/"+nome;
        InputStream stream = servletContext.getResourceAsStream(pathNome);            //getResourceAsStream(path+nome);
        //this.file = new DefaultStreamedContent(stream, "application/octet-stream", nome);
        this.file = new DefaultStreamedContent(stream,"application/pdf", nome);


    }
    
asked by anonymous 09.03.2016 / 13:18

1 answer

2

According to documentation of Primefaces you should set the Ajax property of the button to false

ajax="false"

Basically ajax no commandButton specifies how the page submit will be done. You can find more information on these links:

link link

    
09.03.2016 / 14:02