You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2014/02/02 10:36:09 UTC

[jira] [Commented] (WICKET-4802) Add functionality to be able to export DataTable content

    [ https://issues.apache.org/jira/browse/WICKET-4802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13888881#comment-13888881 ] 

Martin Grigorov commented on WICKET-4802:
-----------------------------------------

There is a small problem with the signature of #getDataModel(). See discussion in dev@: http://markmail.org/message/f533bz3pcpoh6r4e 

> Add functionality to be able to export DataTable content
> --------------------------------------------------------
>
>                 Key: WICKET-4802
>                 URL: https://issues.apache.org/jira/browse/WICKET-4802
>             Project: Wicket
>          Issue Type: New Feature
>          Components: wicket-extensions
>    Affects Versions: 6.1.0
>            Reporter: Jesse Long
>            Assignee: Martin Grigorov
>            Priority: Minor
>             Fix For: 6.2.0
>
>         Attachments: WICKET-4802.patch
>
>
> In Igor's book he describes a way of exporting a data table to CSV. It requires tagging exportable columns with a interface, which allows retrieving of the data for the column by passing it the row model.
> I, and I'm sure many others, have implemented this functionality, and we all have our own CSVExportToolbar, or something similar. The problem is that each export implementation is checking for instances of their own hand-crafted IDataColumn interface. This makes it difficult for people to write libraries that provide columns that will be exportable across the board.
> I propose that we add a standard IDataColumn that can be used to tagging exportable columns, and which every CSVExportToolbar and ExcelExportToolbar etc can check for when determining which columns to use to export.
> Something like:
> /** does not need sort parameter, does not need to extend IColumn */
> public interface IDataColumn<R, T>
> {
>     /** get data for row by passing row model, in imodel format to allow this method to be used for rendering in an abstract implementation. */
>     IModel<T> getDataModel(IModel<R> rowModel);
>     /** get column header, useful in exporting. same signature as AbstractColumn method */
>     IModel<String> getDisplayModel();
> }
> Then an abstract implementation, where the user only needs to implement getDataModel()
> public abstract class AbstractDataColumn<R, S, T>
> extends AbstractColumn<R, S>
> implements IDataColumn<R, T>
> {
>     // normal AbstractColumn constructors.
>     protected Component createNewDisplayComponent(String componentId, IModel<T> dataModel)
>     {
>         return new Label(componentId, dataModel);
>     }
>     @Override
>     public void populateItem(Item<ICellPopulator<R>> cellItem, String componentId, IModel<R> rowModel)
>     {
>         cellItem.add(createNewDisplayComponent(componentId, getDataModel(rowModel)));
>     }
> }



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)