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 <suvojit...@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-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org >