com.github.dandelion.datatables.core.export
Class ExportUtils

java.lang.Object
  extended by com.github.dandelion.datatables.core.export.ExportUtils

public final class ExportUtils
extends Object

Utilities used when exporting data.

Since:
0.9.0
Author:
Thibault Duchateau

Field Summary
static String DDL_DT_REQUESTATTR_EXPORT_CONF
          Request attributes
static String DDL_DT_REQUESTATTR_EXPORT_CONTENT
           
static String DDL_DT_REQUESTPARAM_EXPORT_AUTOSIZE
           
static String DDL_DT_REQUESTPARAM_EXPORT_EXTENSION
           
static String DDL_DT_REQUESTPARAM_EXPORT_FORMAT
           
static String DDL_DT_REQUESTPARAM_EXPORT_HEADER
           
static String DDL_DT_REQUESTPARAM_EXPORT_ID
           
static String DDL_DT_REQUESTPARAM_EXPORT_IN_PROGRESS
          Request parameters
static String DDL_DT_REQUESTPARAM_EXPORT_MIME_TYPE
           
static String DDL_DT_REQUESTPARAM_EXPORT_NAME
           
static String DDL_DT_REQUESTPARAM_EXPORT_ORIENTATION
           
static String DDL_DT_REQUESTPARAM_EXPORT_TYPE
           
 
Method Summary
static String getCurrentExportType(javax.servlet.http.HttpServletRequest request)
           
static Boolean isTableBeingExported(javax.servlet.ServletRequest servletRequest, HtmlTable table)
           Check whether the table if being exported using the request ExportConstants#DDL_DT_REQUESTPARAM_EXPORT_ID attribute.
static void renderExport(HtmlTable table, ExportConf exportConf, javax.servlet.http.HttpServletResponse response)
          Renders the passed table by writing the data to the response.
static void writeToResponse(javax.servlet.http.HttpServletResponse response, ByteArrayOutputStream baos, String title, String contentType)
          Write the given temporary OutputStream to the HTTP response as an Attachment with the given title.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DDL_DT_REQUESTATTR_EXPORT_CONF

public static final String DDL_DT_REQUESTATTR_EXPORT_CONF
Request attributes

See Also:
Constant Field Values

DDL_DT_REQUESTATTR_EXPORT_CONTENT

public static final String DDL_DT_REQUESTATTR_EXPORT_CONTENT
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_IN_PROGRESS

public static final String DDL_DT_REQUESTPARAM_EXPORT_IN_PROGRESS
Request parameters

See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_TYPE

public static final String DDL_DT_REQUESTPARAM_EXPORT_TYPE
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_ID

public static final String DDL_DT_REQUESTPARAM_EXPORT_ID
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_FORMAT

public static final String DDL_DT_REQUESTPARAM_EXPORT_FORMAT
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_ORIENTATION

public static final String DDL_DT_REQUESTPARAM_EXPORT_ORIENTATION
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_HEADER

public static final String DDL_DT_REQUESTPARAM_EXPORT_HEADER
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_MIME_TYPE

public static final String DDL_DT_REQUESTPARAM_EXPORT_MIME_TYPE
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_EXTENSION

public static final String DDL_DT_REQUESTPARAM_EXPORT_EXTENSION
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_NAME

public static final String DDL_DT_REQUESTPARAM_EXPORT_NAME
See Also:
Constant Field Values

DDL_DT_REQUESTPARAM_EXPORT_AUTOSIZE

public static final String DDL_DT_REQUESTPARAM_EXPORT_AUTOSIZE
See Also:
Constant Field Values
Method Detail

renderExport

public static void renderExport(HtmlTable table,
                                ExportConf exportConf,
                                javax.servlet.http.HttpServletResponse response)
Renders the passed table by writing the data to the response.

Parameters:
table - The table to export.
exportConf - The export configuration (e.g. the export class to use).
response - The response to update.

writeToResponse

public static void writeToResponse(javax.servlet.http.HttpServletResponse response,
                                   ByteArrayOutputStream baos,
                                   String title,
                                   String contentType)
                            throws IOException
Write the given temporary OutputStream to the HTTP response as an Attachment with the given title.

Parameters:
response - current HTTP response
baos - the temporary OutputStream to write
title - the title of the attachment
contentType - the MIME type
Throws:
IOException - if writing/flushing failed

getCurrentExportType

public static String getCurrentExportType(javax.servlet.http.HttpServletRequest request)

isTableBeingExported

public static Boolean isTableBeingExported(javax.servlet.ServletRequest servletRequest,
                                           HtmlTable table)

Check whether the table if being exported using the request ExportConstants#DDL_DT_REQUESTPARAM_EXPORT_ID attribute.

The table's id must be tested in case of multiple tables are displayed on the same page and exportable.

Returns:
true if the table is being exported, false otherwise.


Copyright © 2013–2014 Dandelion Project. All rights reserved.