Tabular Extension
The Tabular Extension module integrates with the Wicket Viewer to allow any collection to be downloaded as specific tabular data file (e.g. an Excel spreadsheet).
The viewer automatically makes the "download" menu item available for all tables:
Setup
Dependency Management
In your application’s top level pom.xml
, add a dependency for this module’s own bill of materials (BOM):
pom.xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.causeway.extensions</groupId>
<artifactId>causeway-extensions-tabular</artifactId>
<scope>import</scope>
<type>pom</type>
<version>2.1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Dependencies / Imports
In the webapp module of your application, add the following dependency:
pom.xml
<dependency>
<groupId>org.apache.causeway.extensions</groupId>
<artifactId>causeway-extensions-tabular-excel</artifactId>
</dependency>
In your application’s App Manifest, import the extension’s implementation module:
AppManifest.java
@Configuration
@Import({
CausewayModuleExtTabularExcel.class,
...
})
public class AppManifest {
}
Custom Export (SPI)
To provide a custom exporter, simply implement CollectionContentsExporter
and register with Spring.
Collection Contents Exporter (SPI)
/**
* SPI to provide file export to table views.
*
* @since 2.0 {@index}}
*/
public interface CollectionContentsExporter {
File createExportFile(DataTable dataTable);
CommonMimeType getMimeType();
/**
* @return label for the "View as" dropdown for "collection contents as"
* component factories
*/
String getTitleLabel();
/**
* @return CSS class for the icon/image next to "View as" dropdown
* for "collection contents as" component factories
*/
String getCssClass();
/**
* An ordinal, that governs the order of appearance in the UI dropdown.
* <ul>
* <li>{@literal 1000..1999} reserved for different table presentations</li>
* <li>{@literal 2000..2999} reserved for different table exports</li>
* </ul>
* <p>
* Lowest comes first.
*/
int orderOfAppearanceInUiDropdown();
/**
* Whether activation of this table presentation view should result in a full page reload.
*/
default boolean isPageReloadRequiredOnTableViewActivation() { return false; }
}