I have an editable <p:dataTable>
with <p:cellEditor>
and I want to export the content of that table into PDF format using <p:dataExporter>
.
I have included the itext 2.1.7 jar. I got the output in PDF but it shows the Object#toString()
values of all <p:cellEditor>
components like so:
org.primefaces.component.celleditor.CellEditor@1bd59e1
How do I export the output values of the <p:cellEditor>
instead?
I agree, I also find this approach to customize the Exporter behaviour the most flexible and least painful.
Anyone interested in using the preProcessor/postProcessor methods with this? Here's an example how to do that.
I dared to slightly modify the method from the answer above:
And this is how you use it in your page (again, I just modified the above example):
Notice that there ARE NO NESTED EL STATEMENTS (that is not allowed anyway), the last two arguments are simple Strings containing EL expressions.
The
<p:cellEditor>
is indeed not recognized by the PrimeFaces standard data exporters. I've previously reported this to the PF guys as issue 4013 with an example which not only mentionsCellEditor
, but alsoHtmlGraphicImage
(we are using images to show boolean states, whosealt
we'd like to show in PDF/XML/XLS/CSV reports).First, create a new class which extends the standard
PDFExporter
like follows:Then, to use it, call it programmatically instead of via
<p:dataExporter>
.With
Feel free to find the data table by
UIComponent#findComponent()
instead and to set the filename in action method only. The above code is just exemplary.