DataOption includeCsvExport

Expanders 3.2.1

As of expander version 3.2.1, the dataElement option includeCsvExport option has been added. Using this option will generate the following artifacts:

  1. A <dataElement>ExporterAction class in the control layer.
  2. A <dataElement>ExporterImpl class in the logic layer.
  3. An export-method through the stack
  4. A <dataElement>-io-page html and js file in the view layer.

ExporterAction

  • URL: /<application>/<component>/<dataElement>-download-json
  • 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=’;’)

Upload page

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.

Default implementation

The default implementation will write a CSV file with headers. Fields are mapped using dedicated Mapper-classes.

File layout

The file needs to contain the right headers, and as stated previously, the name field should be present. See ExporterAction for encoding and separator.

Custom Implementation

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.

Known Issues

For expanders version 3.2.1 to 3.2.1.3, 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>

Version

Release Expander version Change
201803 3.2.1 implemented

References