My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 221: filename parameter
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


 
Reported by stas.agarkov, Oct 5, 2009
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 5, 2009
Project Member #1 jeff.johnston.mn@gmail.com
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);
            }
        }
    }



Oct 22, 2009
Project Member #2 jeff.johnston.mn@gmail.com
Did this work for you?
Nov 5, 2009
#3 stas.agarkov
Yes, thank you!
And in the future you will improve the possibility of existing API, so you can do 
without such hacks?

Powered by Google Project Hosting