As of expander version 3.2.1, the dataElement option includeCsvExport option has been added. Using this option will generate the following artifacts:
<dataElement>ExporterActionclass in the control layer.
<dataElement>ExporterImplclass in the logic layer.
export-method through the stack
<dataElement>-io-pagehtml and js file in the view layer.
- method: POST
- parameters: type, parameters
The type refers to the type of the export. In this case, it should always be ‘csv’.
The parameters parameter should be a map with key-value pairs. These are optional values such as:
- ‘encoding’: the encoding used for the export (default=’UTF-8’)
- ‘separator’: the separator character used for the CSV (default=’;’)
A dedicated page is generated at the url:
/<application>/<component>/<dataElement>/data. Here you can download a file with up to 5000 records.
To add this page to the menu, you need to add
<component>-<dataElement>-io-page as a menuItem to the application menu file.
This is only available for the next gen UI.
The default implementation will write a CSV file with headers. Fields are mapped using dedicated Mapper-classes.
The file needs to contain the right headers, and as stated previously, the name field should be present. See ExporterAction for encoding and separator.
If you add a className (with packageName if it is in a different package than the default one) to the value of the dataElementOption, this custom class will be used. This custom class will need to implement the IExporter interface. Here you need to implement the export method yourself.
For expanders version 3.2.1 to 184.108.40.206, there is an issue that occurs if this option is added without adding the
includeCsvImport option. In this case, the expanders will not add the dependency on
nsx-shared-opencsv or expand the io page.
In this case, add the following dependency to the logic layer of the component:
<dependency> <groupId>net.democritus</groupId> <artifactId>nsx-shared-opencsv</artifactId> </dependency>