I'm using PrimeFaces-2.2.1 on Mojarra-2.0.4.
Following Problem:
Defining a site with two links to download pdf files:
Code: Select all
<h:form>
<h:commandLink ajax="false">
<h:outputText value="Pdf 1" />
<p:fileDownload value="#{testBean.getPdf('Pdf 1')}" />
</h:commandLink>
<h:commandLink ajax="false">
<h:outputText value="Pdf 2" />
<p:fileDownload value="#{testBean.getPdf('Pdf 2')}" />
</h:commandLink>
</h:form>
Code: Select all
public StreamedContent getPdf(String value) throws IOException, DocumentException {
Document document = new Document(PageSize.A4);
ByteArrayOutputStream out = new ByteArrayOutputStream();
PdfWriter.getInstance(document, out);
document.open();
document.add(new Phrase(value));
document.close();
return new DefaultStreamedContent(new ByteArrayInputStream(out.toByteArray()),
"application/pdf",
"Doc-"+ value + ".pdf");
}
I think because the site is not refreshed and the hidden input field (for the parameters) is still in the site. So this will post too to the server.