I need to create a list of .pdf files and wrapp it all in one zip file using org.primefaces.model.StreamedContent. Is it possible??? This is my general idea:
private StreamedContent fileDownload;
private ArrayList<StreamedContent> filesDownload;
for (Cobranca boleto : cob) {
this.boletoPDF = null;
TndFabricaBoletoWrapper wrapper = new TndFabricaBoletoWrapper();
wrapper = this.cobrancaBusiness.processarBoleto(boleto, wrapper);
wrapper.setDownload(true);
JBoleto jBoleto = TndFabricaJBoleto.getJBoleto(wrapper);
jBoleto.addBoleto();
this.boletoPDF = jBoleto.closeBoleto();
File anexo = File.createTempFile("Boleto", ".pdf");
Arquivo.salvarArquivo(anexo, this.boletoPDF);
byte[] arq = Arquivo.zipByte(anexo, 9);
this.fileDownload = new DefaultStreamedContent(new ByteArrayInputStream(arq), "application/zip", "Boleto");
this.filesDownload.add(this.fileDownload);
}
((DefaultStreamedContent) this.filesDownload).setName("Boleto" + ".zip"); //this is where the download action usually happens... But the (DefaultStreamdContent) cannot be cast to an ArrayList...