Anand MS
Anand MS

Reputation: 94

p:dataExporter not exporting just the displayed page

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

Answers (2)

murra
murra

Reputation: 11

you should remove pageOnly="true" from your code then it export current page only.

Upvotes: 1

Smutje
Smutje

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

Related Questions