View Source

_Since 3.2_

If none of the standard formats (CSV, PDF, XLS, and XML) is suitable to display data for a given application. It is possible to define a custom format by implementing a custom exporter. It's also possible to extend any of the standard exporters with added features.

{tip}See the ICEfaces Showcase [Live Demo|http://icefaces-showcase.icesoft.org/showcase.jsf?grp=aceMenu&exp=dataExporterCustom] of this component, complete with source code.{tip}

The first step is to create a subclass of {{org.icefaces.ace.component.dataexporter.Exporter}}. Alternatively, you can extend {{CSVExporter}}, {{ExcelExporter}}, {{PDFExporter}}, or {{XMLExporter}}, found in the same package. The only way to understand how to actually implement a custom exporter is to examine the existing exporters and implement a similar procedure for the desired format. Many parts of the code of the existing exporters can be copied over and then replaced where necessary. In broad terms, a custom exporter has to export the headers, then iterate over the table rows, exporting their data, and then export the footer. Make sure to use the available setup and lower-level helper methods to make this process easier.

Once this is done, an instance of the custom exporter has to be made available in a bean. It is recommended to create a new instance of the exporter every time it is requested (i.e. create a new instance in the getter method). Once the instance is available, the bean property is specified in the {{customExporter}} attribute, as seen below.

{code:xml|borderStyle=dashed}
<ace:dataExporter type="csv" target="myTable" fileName="tableData" customExporter="#{bean.customExporter}"/>
{code}