| Issue 221: | filename parameter | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I want choose own caption table and filename independent.
I find code:
protected void renderExport(ExportType exportType, View view) {
try {
CoreContext cc = getCoreContext();
if (exportType == ExportType.CSV) {
new CsvViewExporter(view, cc, response).export();
} else if (exportType == ExportType.EXCEL) {
new ExcelViewExporter(view, cc, response).export();
} else if (exportType == ExportType.JEXCEL) {
new JExcelViewExporter(view, cc, response).export();
} else if (exportType == ExportType.PDF) {
new PdfViewExporter(view, cc, request, response).export();
} else if (exportType == ExportType.PDFP) {
new PdfPViewExporter(view, cc, request, response).export();
}
} catch (Exception e) {
logger.error("Not able to perform the " + exportType + "
export.");
}
}
Why not filename parameter?
Oct 22, 2009
Did this work for you?
Nov 5, 2009
Yes, thank you! And in the future you will improve the possibility of existing API, so you can do without such hacks? |
I totally agree that we need this! There a few things that I would like to do for the exports to make them more flexible. For now you can just do this. Like everything in JMesa, I really try to expose as much as the API as I can so tweaking things to work is not that much work...although I agree that an improvement to the API is needed. /** * Override the renderExport() method so that we can insert a custom file name. */ private static class CustomTableFacade extends TableFacadeImpl { private HttpServletResponse response; private String fileName; public CustomTableFacade(String id, HttpServletRequest request, HttpServletResponse response, JpaContestDrawing drawing) { super(id, request); this.response = response; DateTime startDate = drawing.getStartDate(); DateTime endDate = drawing.getEndDate(); String contestName = drawing.getContest().getName(); fileName = contestName + "_" + startDate.toString("MM-dd-yyyy") + "_" + endDate.toString("MM-dd-yyyy") + ".xls"; } @Override protected void renderExport(ExportType exportType, View view) { try { if (exportType == ExportType.JEXCEL) { new JExcelViewExporter(view, getCoreContext(), response, fileName).export(); } else { super.renderExport(exportType, view); } } catch (Exception e) { logger.error("Not able to perform the " + exportType + " export.", e); } } }