3

I'm using a dataTable inside another dataTable. When I try to export (in any format) using the dataExporter i got something like: "org.primefaces.component.datatable.DataTable@1b675ca" instead of the inner-dataTable values.

Is it a limit of dataExporter? I have to implement this functionality extending dataExporter? Any Alternatives?

Kamahl
  • 246
  • 3
  • 9
  • 2
    Looks like `p:dataExporter>` doesn't know how to export a JSF (this includes PrimeFaces) component at all, which would be normal behavior by now, and yes it is a limit. Read [p:dataExporter does not recognize p:cellEditor](http://stackoverflow.com/a/14413932/1065197) that explains how to handle a similar situation. – Luiggi Mendoza Mar 28 '13 at 13:16

2 Answers2

2

Since my outer DataTable has only one column, and each row is a sub DataTable I have extended the PDFExporter in this way:

@Override
    protected String exportValue(FacesContext context, UIComponent component) {
        if (component instanceof DataTable) {
            DataTable tab = (DataTable) component;
            try {
                document.add(exportPDFTable(context, tab, false, false, "UTF-8"));
            } catch (DocumentException ex) {
                Logger.getLogger(ExtendedPDFExporter.class.getName()).log(Level.SEVERE, null, ex);
            }
             return "";       
        else {
            return super.exportValue(context, component);
        }
    }

where document is created by export method.

The problem now is that each sub DataTable uses dynamic columns, and for those columns in the exported PDF i got the values of the first sub DataTable replicated in each sub DataTable. Any ideas for this?

Kamahl
  • 246
  • 3
  • 9
1

This is limitation of dataExporter you have to make your own exporter to do this. I think it is best to try to override method exportValue from Export class (which is superclass of all custom export classes). Here, if value is not instance of HtmlCommandLink or ValueHolder just toString() is used, so that is why you see this is printed. Additionally you will have to make your action listener which will instantiate your custom classes for exporting.

partlov
  • 13,789
  • 6
  • 63
  • 82