FileDownload streams binary content to the client. It is attached to a command component, here to two non-Ajax buttons that monitor the download with PrimeFaces.monitorDownload() and to an Ajax button. contentDisposition is "attachment" or "inline", which opens the file in the browser if supported; combine "inline" with store="true" so that it is saved with its original name.
<script>
//<![CDATA[
function start() {
PF('statusDialog').show();
}
function stop() {
PF('statusDialog').hide();
}
//]]>
</script>
<div class="card">
<p:dialog modal="true" ref="statusDialog" header="Status" draggable="false" closable="false"
resizable="false">
<i class="pi pi-spinner pi-spin" style="font-size:3rem"></i>
</p:dialog>
<h:form>
<p:commandButton value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop);"
icon="pi pi-arrow-down" styleClass="mr-2">
<p:fileDownload value="#{fileDownloadView.file}"/>
</p:commandButton>
<p:commandButton value="Inline Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop);"
icon="pi pi-arrow-down" styleClass="mr-2">
<p:fileDownload value="#{fileDownloadView.file}" contentDisposition="inline" store="true" />
</p:commandButton>
<p:commandButton value="Ajax Download" icon="pi pi-arrow-down" styleClass="p-button-outlined">
<p:fileDownload value="#{fileDownloadView.file}"/>
</p:commandButton>
</h:form>
</div>