PerShing2014 / jmesa

Automatically exported from code.google.com/p/jmesa
0 stars 0 forks source link

filename parameter #221

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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?

Original issue reported on code.google.com by stas.agarkov on 5 Oct 2009 at 8:10

GoogleCodeExporter commented 8 years ago
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);
            }
        }
    }

Original comment by jeff.johnston.mn@gmail.com on 5 Oct 2009 at 3:07

GoogleCodeExporter commented 8 years ago
Did this work for you?

Original comment by jeff.johnston.mn@gmail.com on 22 Oct 2009 at 5:53

GoogleCodeExporter commented 8 years ago
Yes, thank you!
And in the future you will improve the possibility of existing API, so you can 
do 
without such hacks?

Original comment by stas.agarkov on 5 Nov 2009 at 2:45