1
votes

I have few columns in the Data Table which displays the column name and row values dynamically. But the first column in the data table have the values which has link. when we click that value it redirects to other screen.

Problem is when we export the csv/excel report. The first column which has this hyperlink not displaying the exact values. it shows as below in the excel

org.primefaces.component.column.Column@72d586ad - instead of exact value like "S123456789"

Please suggest how to display the exact value in the excel and csv.

<p:column headerText="#{msg['column.header']}" width="100" styleClass="columnLeft" filterBy="#{sampleDTO.linkNum}" sortBy="#{sampleDTO.linkNum}" id="linkNum">
                            
 <e:dataTableCommandLink id="viewTestLink" index="#{index}" value="#{sampleDTO.linkNum}" bean="#{sampleListBean}" action="viewLinkViewer"
                                                    ajax="false" currentDto="#{sampleDTO}"/>

</p:column>

Thanks in advance Nithyn K

1
What version of PF? I feel like this was fixed a long time ago? - Melloware
its 6.2 version - Nithyn. K
I am using PF 7.0 and my column has <p:link id="lnkUrl" href="#{splunkUrlProvider.getSplunkUrl(row)}" value="#{row.eventCorrelation}" target="_splunk" /> and it exports fine as the value in value. - Melloware
this it will work in 7 version, even i read in forum. But in 6.2 still the same issue. Is there any other work around ? - Nithyn. K
Can you post your exact <p:column code above in your issue? - Melloware

1 Answers

2
votes

OK the reason its happening is because you are using a custom component <e:dataTableCommandLink which is why it can't figure out what text to display.

Here is what I would do use the ExportFunction...

  1. Create a custom exporter my example uses CDI.
@Named
@ApplicationScoped
public class PassthroughColumnExporter {

   public String export(final UIColumn column) {
      String value = StringUtils.EMPTY;
      for (final UIComponent child : column.getChildren()) {
         final Object exportValue = child.getAttributes().get("data-export");
         if (exportValue != null) {
            value = String.valueOf(exportValue);
            break;
         }
      }

      return value;
   }
}
  1. In your XHTML use this custom exporter to export the value you want looking for the data-export attribute.
<p:column exportFunction="#{passthroughColumnExporter.export}">
    <e:dataTableCommandLink value="#{row.displayValue}" data-export="#{row.exportValue}" />                 
</p:column>