You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by suvojit168 <su...@gmail.com> on 2014/11/05 15:47:31 UTC
How to use CSVDataExporter
Hi,
I am trying to export data to csv in my wicket pages. I am using
CSVDataExporter for this purpose. Due to some constraints I am not using it
in conjunction to ExportToolbar. There is a link and on click of the link I
am trying to call exportData() on instance of CSVDataExporter.
I am using AbstractExportableColumn for columns writing data to columns.
However I am getting a compile time error on exportData. Follwoing is the
code (excelDataImport is the link here ):
excelDataImport.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 1L;
protected void onEvent(AjaxRequestTarget target) {
List<IExportableColumn<AffiliateModel, String, String>> columns = new
ArrayList<IExportableColumn<AffiliateModel, String, String>>();
columns.add(new AbstractExportableColumn<AffiliateModel, String,
String>(new Model<String>("Affiliate Name"), "name") {
@Override
public IModel<String> getDataModel(
IModel<AffiliateModel> arg0) {
// TODO Auto-generated method stub
return null;
}
});
try {
new CSVDataExporter().exportData(new AffiliateDataProvider(null),
columns, new FileOutputStream("test.xls"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
The error message is : "The method exportData(IDataProvider<T>,
List<IExportableColumn<T,?,?>>, OutputStream) in the type CSVDataExporter
is not applicable for the arguments (AffiliateDataProvider,
List<IExportableColumn<AffiliateModel,String,String>>,
FileOutputStream)".
I think I did it all correctly (as per whatever knowledge I could get on
this subject), am I doing something wrong here?
Also, can anyone share with me some sample examples and description/details
for CSVDataExporter? I have gone through example in DataTablePage.java in
wicket example but that is using DataTable and ExportToolbar.
Thanks,
Suvojit
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-use-CSVDataExporter-tp4668270.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to use CSVDataExporter
Posted by Sebastien <se...@gmail.com>.
Hi François, Suvojit
Actually the Wicket Kendo UI's DataTable (first example) is using a custom
CSVDataExporter (largely inspired - not to say copy/paste - from the
original). But it can still itself be used for inspiration...
Source:
https://github.com/sebfz1/wicket-jquery-ui/blob/master/wicket-kendo-ui/src/main/java/com/googlecode/wicket/kendo/ui/datatable/export/CSVDataExporter.java
Best regards,
Sebastien
On Thu, Nov 6, 2014 at 2:37 PM, Francois Meillet <francois.meillet@gmail.com
> wrote:
> Hi Suvojit,
>
> I don't know CSVDataExporter but I noticed that the second bounded type
> parameter was a
> wildcard and not a defined type.
>
> I use Wicket 7 where there are only 2 parameters.
>
> See some examples:
>
> http://www.7thweb.net/wicket-jquery-ui/kendo/datatable/CommandsDataTablePage;jsessionid=2926A68F12DAE4CAC910C18699676209?0
>
> https://doc.codelutin.com/cantharella/xref/nc/ird/cantharella/web/utils/data/TableExportToolbar.html
>
>
> François
>
>
> François Meillet
> Formation Wicket - Développement Wicket
>
Re: How to use CSVDataExporter
Posted by Francois Meillet <fr...@gmail.com>.
Hi Suvojit,
I don't know CSVDataExporter but I noticed that the second bounded type parameter was a
wildcard and not a defined type.
I use Wicket 7 where there are only 2 parameters.
See some examples:
http://www.7thweb.net/wicket-jquery-ui/kendo/datatable/CommandsDataTablePage;jsessionid=2926A68F12DAE4CAC910C18699676209?0
https://doc.codelutin.com/cantharella/xref/nc/ird/cantharella/web/utils/data/TableExportToolbar.html
François
François Meillet
Formation Wicket - Développement Wicket
Le 6 nov. 2014 à 13:07, suvojit168 <su...@gmail.com> a écrit :
> Francois Meillet wrote
>> try
>> List<IExportableColumn<AffiliateModel, ?>> columns = new
>> ArrayList<IExportableColumn<AffiliateModel, ?>>();
>
> Hi François,
>
> Thanks for reply. I am using wicket 6.16. As per this Link
> <http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/extensions/markup/html/repeater/data/table/export/IExportableColumn.html>
> we have,
>
> Interface IExportableColumn<T,S,D>
>
> Type Parameters:
> T - The type of each row in the table.
> S - The type of the sort property of the table.
> D - The type of the data displayed by this column.
>
> When I try :
> List<IExportableColumn<AffiliateModel, ?>> columns = new
> ArrayList<IExportableColumn<AffiliateModel, ?>>();
>
> I get compile time error "Incorrect number of arguments for type
> IExportableColumn<T,S,D>; it cannot be parameterized with arguments
> <AffiliateModel, ?>".
>
> Nonetheless, this works :
> List<IExportableColumn<AffiliateModel, ?, ?>> columns = new
> ArrayList<IExportableColumn<AffiliateModel, ?, ?>>();
>
> I am getting a null pointer exception inside exportData (...) now which I am
> looking at. Will add reply if I need assistance.
>
> PS: It will be great if you can share some
> examples/tutorials/articals/anything on CSVDataExporter ( I am not very much
> comfortable with CSVDataExporter as of now).
>
>
> Thanks,
> Suvojit
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-use-CSVDataExporter-tp4668270p4668280.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
Re: How to use CSVDataExporter
Posted by suvojit168 <su...@gmail.com>.
Francois Meillet wrote
> try
> List<IExportableColumn<AffiliateModel, ?>> columns = new
> ArrayList<IExportableColumn<AffiliateModel, ?>>();
Hi François,
Thanks for reply. I am using wicket 6.16. As per this Link
<http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/extensions/markup/html/repeater/data/table/export/IExportableColumn.html>
we have,
Interface IExportableColumn<T,S,D>
Type Parameters:
T - The type of each row in the table.
S - The type of the sort property of the table.
D - The type of the data displayed by this column.
When I try :
List<IExportableColumn<AffiliateModel, ?>> columns = new
ArrayList<IExportableColumn<AffiliateModel, ?>>();
I get compile time error "Incorrect number of arguments for type
IExportableColumn<T,S,D>; it cannot be parameterized with arguments
<AffiliateModel, ?>".
Nonetheless, this works :
List<IExportableColumn<AffiliateModel, ?, ?>> columns = new
ArrayList<IExportableColumn<AffiliateModel, ?, ?>>();
I am getting a null pointer exception inside exportData (...) now which I am
looking at. Will add reply if I need assistance.
PS: It will be great if you can share some
examples/tutorials/articals/anything on CSVDataExporter ( I am not very much
comfortable with CSVDataExporter as of now).
Thanks,
Suvojit
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-use-CSVDataExporter-tp4668270p4668280.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to use CSVDataExporter
Posted by Francois Meillet <fr...@gmail.com>.
We have IExportableColumn<T, S>
where T is the type of each row in the table.
where S is the type of the sort property of the table.
and the method
public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream)
try
List<IExportableColumn<AffiliateModel, ?>> columns = new ArrayList<IExportableColumn<AffiliateModel, ?>>();
François Meillet
Formation Wicket - Développement Wicket
Le 5 nov. 2014 à 15:47, suvojit168 <su...@gmail.com> a écrit :
> Hi,
>
> I am trying to export data to csv in my wicket pages. I am using
> CSVDataExporter for this purpose. Due to some constraints I am not using it
> in conjunction to ExportToolbar. There is a link and on click of the link I
> am trying to call exportData() on instance of CSVDataExporter.
> I am using AbstractExportableColumn for columns writing data to columns.
>
> However I am getting a compile time error on exportData. Follwoing is the
> code (excelDataImport is the link here ):
>
> excelDataImport.add(new AjaxEventBehavior("onclick") {
> private static final long serialVersionUID = 1L;
>
> protected void onEvent(AjaxRequestTarget target) {
> List<IExportableColumn<AffiliateModel, String, String>> columns = new
> ArrayList<IExportableColumn<AffiliateModel, String, String>>();
> columns.add(new AbstractExportableColumn<AffiliateModel, String,
> String>(new Model<String>("Affiliate Name"), "name") {
>
> @Override
> public IModel<String> getDataModel(
> IModel<AffiliateModel> arg0) {
> // TODO Auto-generated method stub
> return null;
> }
>
> });
>
> try {
> new CSVDataExporter().exportData(new AffiliateDataProvider(null),
> columns, new FileOutputStream("test.xls"));
> } catch (FileNotFoundException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
>
>
>
> }
> });
>
> The error message is : "The method exportData(IDataProvider<T>,
> List<IExportableColumn<T,?,?>>, OutputStream) in the type CSVDataExporter
> is not applicable for the arguments (AffiliateDataProvider,
> List<IExportableColumn<AffiliateModel,String,String>>,
> FileOutputStream)".
>
> I think I did it all correctly (as per whatever knowledge I could get on
> this subject), am I doing something wrong here?
>
> Also, can anyone share with me some sample examples and description/details
> for CSVDataExporter? I have gone through example in DataTablePage.java in
> wicket example but that is using DataTable and ExportToolbar.
>
> Thanks,
> Suvojit
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-use-CSVDataExporter-tp4668270.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>