Firefox warning "unreachable code after return statement" for non-ajax CommandLink

UI Components for JSF
Post Reply
Posts: 2
Joined: 03 May 2018, 17:13
Location: Würzburg, Germany

18 May 2018, 11:49


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" />
The reason for the warning seems to be the generated onClick code for the commandLink:

Code: Select all

<a onclick="PrimeFaces.monitorDownload(onDownloadStart, onDownloadStop);;PrimeFaces.addSubmitParam('theform',{'[removed]'}).submit('theform');return false;PrimeFaces.onPost();">Download</a>
There is indeed a "return" followed by "PrimeFaces.onPost()".

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");
            if (target != null) {

            request.append(");return false;");

        if (!submit && !params.isEmpty()) {

        return request.toString();
So, my question is:
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

Expert Member
Posts: 9231
Joined: 17 Jun 2010, 13:34
Location: Netherlands

18 May 2018, 15:51

Sounds logical... Can you try with changed source if you notice a difference in behaviour? If not, please file an issue and maybe even a pull request
Ronald van Kuijk
PrimeFaces 6.1, PrimeFaces plus 0.0.2 | JbossWildfly 10.1| Mojarra 2.2.13
Fedora 61, Firefox 'most recent'
Read the forum posting rules

Posts: 2
Joined: 03 May 2018, 17:13
Location: Würzburg, Germany

22 May 2018, 18:09

I created an issue and a pull request for this problem now:

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Melloware and 9 guests