Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.2
-
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.
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
- blocks
-
ICE-7191 Develop portlet version of latest ACE showcase application
- Closed
Activity
Deryk Sinotte
created issue -
Deryk Sinotte
made changes -
Field | Original Value | New Value |
---|---|---|
Assignee | Ken Fyten [ ken.fyten ] |
Deryk Sinotte
made changes -
Ken Fyten
made changes -
Salesforce Case | [] | |
Assignee Priority | P1 | |
Assignee | Ken Fyten [ ken.fyten ] | yip.ng [ yip.ng ] |
yip.ng
made changes -
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Ken Fyten
made changes -
Fix Version/s | 2.1-Beta [ 10291 ] |
Ken Fyten
made changes -
Status | Resolved [ 5 ] | Closed [ 6 ] |
Ken can assign to the appropriate resource to fix.