0

I tried to export the data from my datatable but when I press the pdf button for example it refresh the page without export

   <h:commandLink  >
        <p:graphicImage value="/images/excel.png" />
        <p:dataExporter type="xls" target="dataTable" fileName="alarms" />
    </h:commandLink>

    <h:commandLink  >
        <p:graphicImage value="/images/pdf.png" />
        <p:dataExporter type="pdf" target="dataTable"  fileName="alarms"/>
    </h:commandLink>

      <h:commandLink  >
        <p:graphicImage value="/images/csv.png" />
        <p:dataExporter type="csv" target="dataTable" fileName="alarms" />
    </h:commandLink>
user3516948
  • 13
  • 1
  • 2
  • 8

2 Answers2

0

<p:commandLink> has to be surrounded by <h:form> tag to work. If this is not the problem can you please provide the source code of your whole page and the PrimeFaces version you are working with?

LarsBauer
  • 1,539
  • 18
  • 23
0
<h:commandLink style=" text-align: right!important;"
    immediate="true" id="excelLinkId" ajax="false" >
        <p:dataExporter type="xls" target="myTable" fileName="myExcel" />
</h:commandLink>
  • please add more explanation to the code why the OP should use it, rather than dumping the code – Muhammad Omer Aslam Sep 10 '18 at 12:51
  • With immediate="true" on the button, the action is indeed invoked during apply request values phase and all the remaining phases are skipped. That's also the sole point of this attribute: process (decode, validate, update and invoke) the component immediately during apply request values phase. https://stackoverflow.com/questions/12960718/trying-to-understand-immediate-true-skipping-inputs-when-it-shouldnt – Hakan Anlamaz Sep 10 '18 at 13:17
  • good, now add this explanation into your answer by clicking on [Edit](https://stackoverflow.com/posts/52256130/edit). – Muhammad Omer Aslam Sep 10 '18 at 13:18