0

I need your assistant in controlling the sequence of firing two java methods. In the JSF Form, I am having a commandLink that calls a method "GeneratePDF" and it will allow the user to download a PDF file. Later on a second call to a method "UpdateDataTable" that will run a SQL statement and then it will update the dataTable in the JSF form.

In the below code the second method "UpdateDataTable" is not called and the only method which is called is the "GeneratePDF". The code is:

 <p:commandLink id="exporter" actionListener="#{exstaff.GeneratePDF}" ajax="false" oncomplete="updateremote()">
     <h:graphicImage name="/images/PDF.png" alt="Export to PDF"/>
         <p:fileDownload value="#{exstaff.pdfFile}"/>
 </p:commandLink>
 <p:remoteCommand id="updateremote" value="updateremote" actionListener="#{exstaff.UpdateDataTable}"/>

I tried to change the onComplete to onSuccess, but unfortunately the UpdateDataTable method is not called. Also, I tried the onClick and it will fire first the UpdateDataTable method and then the GeneratePDf method. But in my case, I want to fire the GeneratePDF and then the UpdateDataTable .

99maas
  • 1,239
  • 12
  • 34
  • 59
  • The duplicate basically shows how to first do "generatePDF" (and "updateDataTable") and then "download". – BalusC Jul 27 '16 at 13:14
  • wow, three times the same question in 24 hours – Kukeltje Jul 27 '16 at 14:40
  • @BalusC Thanks for your hints, but still I can't understand how to solve it properly. First I will generate the PDF, at the end of the GeneratePDF method, I am having--> ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); StreamedContent file = new DefaultStreamedContent(in, "application/pdf", "sample.pdf"); , so after these two lines I should call the method updateDataTable and to update the components? – 99maas Jul 27 '16 at 16:30

0 Answers0