List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.table.export IExportableColumn getDataModel
IModel<?> getDataModel(IModel<T> rowModel);
From source file:org.wicketstuff.poi.datatable.export.AbstractExcelDataExporter.java
License:Apache License
/** * Populates a cell of exported data. This can be overridden to provide custom cell population behavior, or to decorate the * cell./*from ww w . j a v a 2s. c om*/ * * @param <T> The type of each exported row. * @param cell The {@link Cell} to be populated. * @param rowModel The {@link IModel} of the row. * @param column The {@link IExportableColumn} for which this cell if being populated. * @param rowIndex The zero based index of this row in the data set. If headers are exported. then the row index in the * spreadsheet will be one more than this, because the first row of the spreadsheet contains headers. * @param columnIndex The zero based index of the column. * @param workbook The {@link Workbook} in which the cell is created. This is included to than it may be used to create * formatting objects etc. */ @SuppressWarnings("unchecked") protected <T> void populateCell(Cell cell, IModel<T> rowModel, IExportableColumn<T, ?> column, int rowIndex, int columnIndex, Workbook workbook) { IModel<?> cellModel = column.getDataModel(rowModel); if (cellModel != null) { Object cellValue = cellModel.getObject(); if (cellValue != null) { if (cellValue instanceof Boolean) { cell.setCellValue(((Boolean) cellValue).booleanValue()); } else if (cellValue instanceof Number) { cell.setCellValue(((Number) cellValue).doubleValue()); } else if (cellValue instanceof Date) { cell.setCellValue((Date) cellValue); } else { Class<?> c = cellValue.getClass(); String s; IConverter converter = Application.get().getConverterLocator().getConverter(c); if (converter == null) { s = cellValue.toString(); } else { s = converter.convertToString(cellValue, Session.get().getLocale()); } cell.setCellValue(s); } } } }