Class ExportAction

All Implemented Interfaces:
ExecutableAction, SecuredAction, TargetAction<ListDataComponent<Object>>, Action, HasShortcutCombination, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
ExcelExportAction, JsonExportAction

@ActionType("grdexp_export") public class ExportAction extends ListDataComponentAction<ExportAction,Object> implements org.springframework.context.ApplicationContextAware
Base action for export table content with defined exporter. dataGridExporter is required for this action

Should be defined for a list component (Table, DataGrid, etc.).

  • Field Details

    • ID

      public static final String ID
      See Also:
    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
    • messages

      protected Messages messages
    • downloader

      protected Downloader downloader
    • dialogs

      protected Dialogs dialogs
    • dataGridExporter

      protected DataGridExporter dataGridExporter
    • availableExportModes

      protected List<ExportMode> availableExportModes
    • columnsToExport

      protected ColumnsToExport columnsToExport
    • columnsExportFilter

      protected Predicate<com.vaadin.flow.component.grid.Grid.Column<Object>> columnsExportFilter
    • columnKeysToExport

      protected List<String> columnKeysToExport
  • Constructor Details

    • ExportAction

      public ExportAction()
    • ExportAction

      public ExportAction(String id)
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • setMessages

      @Autowired public void setMessages(Messages messages)
    • setDownloader

      @Autowired public void setDownloader(Downloader downloader)
    • setDialogs

      @Autowired public void setDialogs(Dialogs dialogs)
    • setGridExportProperties

      @Autowired public void setGridExportProperties(GridExportProperties gridExportProperties)
    • setColumnsToExport

      public void setColumnsToExport(ColumnsToExport columnsToExport)
      Sets the ColumnsToExport that is used to filter columns to export. This is a simple, predefined alternative to setColumnsExportFilter(Predicate). Has the lowest filtering priority.

      The default value depends on GridExportProperties.getDefaultColumnsToExport().

      Parameters:
      columnsToExport - ColumnsToExport that is used to filter columns to export
    • withColumnsToExport

      public ExportAction withColumnsToExport(ColumnsToExport columnsToExport)
      Returns:
      this
      See Also:
    • setColumnsExportFilter

      public void setColumnsExportFilter(Predicate<com.vaadin.flow.component.grid.Grid.Column<Object>> columnsExportFilter)
      Sets the Predicate that is used to filter columns to export. This is a flexible alternative to setColumnsToExport(ColumnsToExport). Has secondary filtering priority.
      Parameters:
      columnsExportFilter - column export predicate to set
    • withColumnsExportFilter

      public ExportAction withColumnsExportFilter(Predicate<com.vaadin.flow.component.grid.Grid.Column<Object>> columnsExportFilter)
      Returns:
      this
      See Also:
    • setColumnKeysToExport

      public void setColumnKeysToExport(List<String> columnKeysToExport)
      Sets a list of column keys to use for export. Has primary filtering priority.
      Parameters:
      columnKeysToExport - list of column keys
    • withColumnKeysToExport

      public ExportAction withColumnKeysToExport(List<String> columnKeysToExport)
      Returns:
      this
      See Also:
    • setAvailableExportModes

      public void setAvailableExportModes(List<ExportMode> availableExportModes)
      Sets the export modes that will be available in the export option dialog.
      Parameters:
      availableExportModes - export modes to set
    • withAvailableExportModes

      public ExportAction withAvailableExportModes(List<ExportMode> availableExportModes)
      Returns:
      this
      See Also:
    • setDataGridExporter

      public void setDataGridExporter(DataGridExporter dataGridExporter)
      Sets the dataGrid exporter instance
    • withExporter

      public <T> T withExporter(Class<T> exporterClass)
    • setFileName

      public void setFileName(String fileName)
      Sets a file name.
      Parameters:
      fileName - a file name
    • withFileName

      public <T> T withFileName(String fileName)
      Sets a file name.
      Parameters:
      fileName - a file name
      Returns:
      builder
    • addColumnValueProvider

      public void addColumnValueProvider(String columnId, Function<DataGridExporter.ColumnValueContext,Object> columnValueProvider)
      Adds a function to get value from the column.
      Parameters:
      columnId - column id
      columnValueProvider - column value provider function
    • removeColumnValueProvider

      public void removeColumnValueProvider(String columnId)
      Removes an column value provider function by column id.
      Parameters:
      columnId - column id
    • getColumnValueProvider

      @Nullable public Function<DataGridExporter.ColumnValueContext,Object> getColumnValueProvider(String columnId)
      Parameters:
      columnId - column id
      Returns:
      column value provider function for the column id
    • execute

      public void execute()
      Description copied from interface: ExecutableAction
      Executes the Action
      Specified by:
      execute in interface ExecutableAction
    • definePrimaryFilterPredicate

      protected Predicate<com.vaadin.flow.component.grid.Grid.Column<Object>> definePrimaryFilterPredicate()
    • doExport

      protected void doExport(ExportMode exportMode, Predicate<com.vaadin.flow.component.grid.Grid.Column<Object>> primaryFilterPredicate)
    • getMessage

      protected String getMessage(String id)
    • createExportSelectedAction

      protected Action createExportSelectedAction(Predicate<com.vaadin.flow.component.grid.Grid.Column<Object>> primaryFilterPredicate)
    • createExportAllAction

      protected Action createExportAllAction(Predicate<com.vaadin.flow.component.grid.Grid.Column<Object>> primaryFilterPredicate)
    • createCurrentPageAction

      protected Action createCurrentPageAction(Predicate<com.vaadin.flow.component.grid.Grid.Column<Object>> primaryFilterPredicate)
    • isDataLoaderExist

      protected boolean isDataLoaderExist(ListDataComponent<?> target)