Reputation: 94
I'm doing project in PrimeFaces. I want export datatable data using dataexporter. My problem is using a dataexporter attribute to export the current displayed page content. I try this below code:
<p:dataTable id="tbl" var="car" value="#{dataExporterView.employee}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink}
{PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
paginator="true" rows="10" style="margin-bottom:20px">
............................
<h:commandLink>
<p:graphicImage name="/demo/images/xml.png" />
<p:dataExporter type="pdf" target="tbl" fileName="employee" pageOnly="true" />
</h:commandLink>
</p:dataTable>
But even though I added pageOnly="true"
, it will export all pages but I want export particular displayed page only.
Upvotes: 2
Views: 2503
Reputation: 11
you should remove pageOnly="true" from your code then it export current page only.
Upvotes: 1
Reputation: 18143
You cannot export particular pages of a p:dataTable
, but you can add a pre or post processor changing the exported content similar to
<p:dataExporter preProcessor="#{bean.preProcessExport}"
postProcessor="#{bean.postProcessExport}"/>
with
public void preProcessExport(Object document) {
if (document instanceof com.lowagie.text.Document) {
// ...
}
}
public void postProcessExport(Object document) {
if (document instanceof com.lowagie.text.Document) {
// ...
}
}
Upvotes: 1