FileDownload was retired from PrimeFaces Extensions and moved to PrimeFaces as p:fileDownload.
It sends a file to the browser from an action of a command component.
Add p:fileDownload with a StreamedContent value to a non-ajax command component.
<div class="card">
<h5>Basic</h5>
<p>Add <code>p:fileDownload</code> with a <code>StreamedContent</code> value to a non-ajax command component.</p>
<h:form id="formBasic">
<p:commandButton value="Download" icon="pi pi-download" ajax="false">
<p:fileDownload value="#{fileDownloadController.file}"/>
</p:commandButton>
</h:form>
</div>
package org.primefaces.extensions.showcase.controller;
import jakarta.enterprise.context.RequestScoped;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Named;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
/**
* Provides a file for the download example (the PrimeFaces <code>p:fileDownload</code>, which replaced the former PrimeFaces Extensions FileDownload).
*/
@Named
@RequestScoped
public class FileDownloadController {
public StreamedContent getFile() {
final ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
return DefaultStreamedContent.builder()
.name("hood.pdf")
.contentType("application/pdf")
.stream(() -> externalContext.getResourceAsStream("/resources/books/hood.pdf"))
.build();
}
}