By 99maas


2016-06-22 17:03:49 8 Comments

I need your help in updating the dataTable component after the user clicks on the fileDownload in primefaces. The case is that the user will click on the download file and it will download the file and at the same time, it will update the count column in the dataTableThe. The jsf code for the download file in the dataTable is:

<p:column headerText="View">
    <p:commandLink id="exporter" actionListener="#{exstaff.GeneratePDF}" ajax="false">
    <h:graphicImage name="/images/PDF.png"/>
        <p:fileDownload value="#{exstaff.pdfFile}"/>
    </p:commandLink>
</p:column>

In the GenearetPDF method, I am allowing the user to download a PDF file which is downloaded properly, however, at the end of the GeneratePDF() method, I am updating the dataTable using the code:

RequestContext context = RequestContext.getCurrentInstance();
context.update("@form");

But because the ajax is false, the dataTable is not updated, so how can I execute the above code? If I enable the ajax, the downloadfile will not work.

1 comments

@Franky 2016-06-23 08:25:25

You can add a remote command:

<p:column headerText="View">
<p:commandLink id="exporter" actionListener="#{exstaff.GeneratePDF}" ajax="false" 
onstart="callRC()">
<h:graphicImage name="/images/PDF.png"/>
    <p:fileDownload value="#{exstaff.pdfFile}"/>
</p:commandLink>

And in the form to be updated:

<form id="yourForm">
  <p:remoteCommand name="callRC" update="@form"/>
</form>

@99maas 2016-06-23 16:03:17

Thanks for your help... I have just tried to do it, however the components will be refreshed first and then the file will be downloaded. In my case, I want the first sequence is to download the file and to call the GeneratePDF and then the form components should be updated . So how can I do that?

@Franky 2016-06-24 09:24:10

take a look to this similar question stackoverflow.com/questions/15744778/…

Related Questions

Sponsored Content

31 Answered Questions

[SOLVED] How to manage a redirect request after a jQuery Ajax call

14 Answered Questions

0 Answered Questions

How to control the sequence of firing the java methods

1 Answered Questions

[SOLVED] Primefaces datatable pagination not working after an update

  • 2016-01-04 09:53:09
  • Abilash
  • 2824 View
  • 0 Score
  • 1 Answer
  • Tags:   jsf-2 primefaces

1 Answered Questions

0 Answered Questions

<p:dialog> is not opening on setting ajax=false for <p:upload>

  • 2015-07-25 19:08:51
  • Little Stars
  • 371 View
  • 0 Score
  • 0 Answer
  • Tags:   jsf primefaces

1 Answered Questions

2 Answered Questions

[SOLVED] primefaces update datatable rows

0 Answered Questions

primefaces p:commandLink in p:datatable doesn't work

2 Answered Questions

Sponsored Content