Class CSVDataExporter

    • Constructor Detail

      • CSVDataExporter

        public CSVDataExporter()
        Constructor
      • CSVDataExporter

        public CSVDataExporter​(String contentType)
        Constructor
        Parameters:
        contentType - the content-type, ie: text/csv
    • Method Detail

      • isExportHeadersEnabled

        public boolean isExportHeadersEnabled()
        Indicates whether headers will be written to the output
        Specified by:
        isExportHeadersEnabled in interface IDataExporter
        Returns:
        true or false
      • quoteValue

        protected String quoteValue​(String value)
        Quotes a value for export to CSV.
        According to RFC4180, this should just duplicate all occurrences of the quote character and wrap the result in the quote character.
        Parameters:
        value - The value to be quoted.
        Returns:
        a quoted copy of the value.
      • exportData

        public <T> void exportData​(org.apache.wicket.markup.repeater.data.IDataProvider<T> provider,
                                   List<IExportableColumn> columns,
                                   OutputStream output,
                                   long first,
                                   long count)
                            throws IOException
        Exports the data provided by the IDataProvider to the OutputStream.
        Type Parameters:
        T - the object type
        Parameters:
        provider - the IDataProvider
        columns - the list of IColumn
        output - the OutputStream
        first - the first row of datacount
        count - the number of elements to retrieve
        Throws:
        IOException - if this could not write the file out
      • export

        public static void export​(DataTable<?> table,
                                  String filename)
      • export

        public static void export​(org.apache.wicket.request.cycle.RequestCycle cycle,
                                  DataTable<?> table,
                                  String filename)
        Exports DataTable data to a CSV file
        Parameters:
        cycle - the RequestCycle
        table - the DataTable
        filename - the file name of the output
      • export

        public static void export​(org.apache.wicket.request.cycle.RequestCycle cycle,
                                  org.apache.wicket.markup.repeater.data.IDataProvider<?> provider,
                                  List<IExportableColumn> columns,
                                  String filename)
        Exports DataTable data to a CSV file
        Parameters:
        cycle - the RequestCycle
        provider - the IDataProvider
        columns - the list of IExportableColumn
        filename - the file name of the output
      • newAjaxDownloadBehavior

        public static org.apache.wicket.extensions.ajax.AjaxDownloadBehavior newAjaxDownloadBehavior​(DataTable<?> table,
                                                                                                     String filename)
        Gets a new AjaxDownloadBehavior that allows to export DataTable data to a CSV file
        Parameters:
        table - the DataTable
        filename - the file name of the output
        Returns:
        a new AjaxDownloadBehavior
      • newAjaxDownloadBehavior

        public static org.apache.wicket.extensions.ajax.AjaxDownloadBehavior newAjaxDownloadBehavior​(org.apache.wicket.markup.repeater.data.IDataProvider<?> provider,
                                                                                                     List<IExportableColumn> columns,
                                                                                                     String filename)
        Gets a new AjaxDownloadBehavior that allows to export DataTable data to a CSV file
        Parameters:
        provider - the IDataProvider
        columns - the list of IExportableColumn
        filename - the file name of the output
        Returns:
        a new AjaxDownloadBehavior