I am using a <p:commandLink ajax="false" /> with a <p:fileDownload /> to provide a downloadable File (ajax=false is required for the download to work).
The download works fine, but when I click the Link in Firefox, I also get an annoying Console-Warning "unreachable code after return statement" (this one).
Code: Select all
<p:commandLink onclick="PrimeFaces.monitorDownload(onDownloadStart, onDownloadStop);" ajax="false">
<p:fileDownload value='#{downloadBean.downloadExcel([...])}' contentDisposition="attachment" />
Download
</p:commandLink>
Code: Select all
<a onclick="PrimeFaces.monitorDownload(onDownloadStart, onDownloadStop);;PrimeFaces.addSubmitParam('theform',{'[removed]'}).submit('theform');return false;PrimeFaces.onPost();">Download</a>
It seems to come from the CoreRenderer in the function buildNonAjaxRequest():
Code: Select all
[...] // submit = true here
if (submit) {
Object target = component.getAttributes().get("target");
request.append(".submit('").append(formId).append("'");
if (target != null) {
request.append(",'").append(target).append("'");
}
request.append(");return false;");
}
if (!submit && !params.isEmpty()) {
request.append(";");
}
request.append("PrimeFaces.onPost();");
return request.toString();
1) is the "return false" here correct?
2) wouldn't it then make sense to print the "PrimeFaces.onPost()" only for submit==false (because due to the "return" it won't be executed anyways)?
PrimeFaces version: 6.2.4
JSF: 2.2
Browser: Firefox 60.0