ICEfaces
  1. ICEfaces
  2. ICE-7226

ACE exporters use servlet specific APIs

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.1-Beta, 3.0
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      ICEfaces 2 ACE exporters portlets
    • Assignee Priority:
      P1

      Description

      In order to support running in a portlet, it's imperative the core, component, and application related code use standard JSF APIs whenever possible and avoid any casting to classes or using methods that are not agnostic to the environment they are running in.

      In the various ACE exporter classes (CSVExporter, PDFExporter, XMLExporter, ExcelExporter) we have code that looks like this (from CSVExporter.export):

      ...
      HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
      OutputStream os = response.getOutputStream();
      OutputStreamWriter osw = new OutputStreamWriter(os , encodingType);
      PrintWriter writer = new PrintWriter(osw);
      ...
           response.setContentType("text/csv");
           response.setHeader("Expires", "0");
              response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
              response.setHeader("Pragma", "public");
              response.setHeader("Content-disposition", "attachment;filename="+ filename + ".csv");
              
              writer.flush();
              writer.close();
              
              response.getOutputStream().flush();
      }

      Casting to HttpServletResponse causes a problem when running in a portlet. The JSF way to do this which avoids the casting exception with portlets:

      ...
              ExternalContext ec = facesContext.getExternalContext();
      OutputStream os = ec.getResponseOutputStream();
      OutputStreamWriter osw = new OutputStreamWriter(os , encodingType);
      PrintWriter writer = new PrintWriter(osw);
      ...
           ec.setResponseContentType("text/csv");
           ec.setResponseHeader("Expires", "0");
              ec.setResponseHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
              ec.setResponseHeader("Pragma", "public");
              ec.setResponseHeader("Content-disposition", "attachment;filename=" + filename + ".csv");
              
              writer.flush();
              writer.close();
              
              os.flush();
      }

      All of the current exporters I noted need to have this corrected. Perhaps some common code could be lifted up to the parent abstract Exporter class.

        Issue Links

          Activity

          Hide
          Deryk Sinotte added a comment -

          Ken can assign to the appropriate resource to fix.

          Show
          Deryk Sinotte added a comment - Ken can assign to the appropriate resource to fix.
          Hide
          Deryk Sinotte added a comment -

          Linking to parent case.

          Show
          Deryk Sinotte added a comment - Linking to parent case.
          Hide
          yip.ng added a comment -

          Exception when exporting excel format:

          java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook

          Show
          yip.ng added a comment - Exception when exporting excel format: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook
          Hide
          yip.ng added a comment -

          Need to include new version of poi.jar.

          Show
          yip.ng added a comment - Need to include new version of poi.jar.
          Hide
          yip.ng added a comment -

          Revision: 25637


          Modified : /icefaces-ee/scratchpads/grimlock/icefaces/ace/component/src/org/icefaces/ace/component/export/CSVExporter.java
          Modified : /icefaces-ee/scratchpads/grimlock/icefaces/ace/component/src/org/icefaces/ace/component/export/ExcelExporter.java
          Modified : /icefaces-ee/scratchpads/grimlock/icefaces/ace/component/src/org/icefaces/ace/component/export/PDFExporter.java
          Modified : /icefaces-ee/scratchpads/grimlock/icefaces/ace/component/src/org/icefaces/ace/component/export/XMLExporter.java

          Show
          yip.ng added a comment - Revision: 25637 Modified : /icefaces-ee/scratchpads/grimlock/icefaces/ace/component/src/org/icefaces/ace/component/export/CSVExporter.java Modified : /icefaces-ee/scratchpads/grimlock/icefaces/ace/component/src/org/icefaces/ace/component/export/ExcelExporter.java Modified : /icefaces-ee/scratchpads/grimlock/icefaces/ace/component/src/org/icefaces/ace/component/export/PDFExporter.java Modified : /icefaces-ee/scratchpads/grimlock/icefaces/ace/component/src/org/icefaces/ace/component/export/XMLExporter.java

            People

            • Assignee:
              yip.ng
              Reporter:
              Deryk Sinotte
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: