String exportContainerStyle = TableConfig.EXPORT_CONTAINER_STYLE.valueFrom(table);
String exportContainerClass = TableConfig.EXPORT_CONTAINER_CLASS.valueFrom(table);
// In order to be easily positioned around the table, a DataTable
// feature is created
ExtraHtml extraHtml = new ExtraHtml();
extraHtml.setUid("E");
extraHtml.setContainer("div");
extraHtml.setCssClass("dataTables_export "
+ (StringUtils.isNotBlank(exportContainerClass) ? exportContainerClass : ""));
extraHtml.setCssStyle(StringUtils.isNotBlank(exportContainerStyle) ? exportContainerStyle : "float: right;");
String dom = TableConfig.FEATURE_DOM.valueFrom(table);
if (StringUtils.isBlank(dom)) {
addParameter(DTConstants.DT_DOM, "lEfrtip", Mode.OVERRIDE);
}
StringBuilder content = new StringBuilder();
HtmlHyperlink link = null;
// A HTML link is generated for each ExportConf bean
for (ExportConf conf : table.getTableConfiguration().getExportConfiguration().values()) {
link = new HtmlHyperlink();
if (conf.getCssClass() != null) {
link.setCssClass(conf.getCssClass());
}
if (conf.getCssStyle() != null) {
link.setCssStyle(conf.getCssStyle());
link.addCssStyle(";margin-left:2px;");
}
else {
link.addCssStyle("margin-left:2px;");
}
if (conf.hasCustomUrl()) {
link.setOnclick(getOnclick(conf));
}
else {
link.setHref(conf.getUrl());
}
link.addContent(conf.getLabel());
content.append(link.toHtml());
}
extraHtml.setContent(content.toString());
// Once created, the extraHtml is transformed into Javascript and
// appended in the DataTables configuration
appendToAfterStartDocumentReady(JavascriptGenerator.INDENTATION);
appendToAfterStartDocumentReady(extraHtml.getJavascript().toString());
appendToAfterStartDocumentReady(JavascriptGenerator.NEWLINE);
}