[
https://issues.jboss.org/browse/RF-13647?page=com.atlassian.jira.plugin.s...
]
Brian Leathem updated RF-13647:
-------------------------------
Steps to Reproduce:
Here's my code from xhtml
{code}
<h:commandLink action="#{campaignBean.campaignDownload()}"
value="#{ifn:translate('Excel File')}"/>
{code}
Backing bean code
{code}
public void campaignDownload() throws Exception {
File f= new File(logDir + fileName);
/* This is an Omnifaces Utility which will simply gives the file to browser. I
tried that but it didn't work either
The same code works fine in 4.3.5 Final and 4.3.4 Final.
http://stackoverflow.com/questions/9391838/how-to-stream-a-file-download-...
*/
//Faces.sendFile(f,true);
try {
FacesContext context = FacesContext.getCurrentInstance();
/* Code that reads content from file and store it in object */
IBinaryContentProvider binaryContentProvider =
dfAction.getBinaryContentProvider();
HttpServletResponse response = (HttpServletResponse)
context.getExternalContext().getResponse();
response.setContentType(binaryContentProvider.getContentMIMEType());
response.setHeader("Content-Disposition", "attachment;
filename="
+ binaryContentProvider.getDownloadFilename());
ServletOutputStream ouputStream = response.getOutputStream();
while (binaryContentProvider.hasMoreChunks()) {
byte[] bytes = binaryContentProvider.getNextChunk();
// it is ok to have 0 bytes
if (bytes != null && bytes.length > 0) {
ouputStream.write(bytes);
}
}
} catch (Exception ex) {
logger.error(Level.SEVERE, "Exception : " + ex);
} finally {
FacesContext.getCurrentInstance().responseComplete();
}
}
{code}
was:
Here's my code from xhtml
<h:commandLink action="#{campaignBean.campaignDownload()}"
value="#{ifn:translate('Excel File')}"/>
Backing bean code
public void campaignDownload() throws Exception {
File f= new File(logDir + fileName);
/* This is an Omnifaces Utility which will simply gives the file to browser. I
tried that but it didn't work either
The same code works fine in 4.3.5 Final and 4.3.4 Final.
http://stackoverflow.com/questions/9391838/how-to-stream-a-file-download-...
*/
//Faces.sendFile(f,true);
try {
FacesContext context = FacesContext.getCurrentInstance();
/* Code that reads content from file and store it in object */
IBinaryContentProvider binaryContentProvider =
dfAction.getBinaryContentProvider();
HttpServletResponse response = (HttpServletResponse)
context.getExternalContext().getResponse();
response.setContentType(binaryContentProvider.getContentMIMEType());
response.setHeader("Content-Disposition", "attachment;
filename="
+ binaryContentProvider.getDownloadFilename());
ServletOutputStream ouputStream = response.getOutputStream();
while (binaryContentProvider.hasMoreChunks()) {
byte[] bytes = binaryContentProvider.getNextChunk();
// it is ok to have 0 bytes
if (bytes != null && bytes.length > 0) {
ouputStream.write(bytes);
}
}
} catch (Exception ex) {
logger.error(Level.SEVERE, "Exception : " + ex);
} finally {
FacesContext.getCurrentInstance().responseComplete();
}
}
File Download throws exception
------------------------------
Key: RF-13647
URL:
https://issues.jboss.org/browse/RF-13647
Project: RichFaces
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: core
Affects Versions: 4.3.6
Environment: Richfaces 4.3.6 Final.
Mojarra - 2.1.28
Weblogic 12.1.2
Windows 7
Reporter: santhosh siravuri
Priority: Critical
File download action throws below exception.
]] Root cause of ServletException.
java.lang.NullPointerException
at
org.richfaces.renderkit.AjaxCommandRendererBase.isSubmitted(AjaxCommandRendererBase.java:83)
at
org.richfaces.renderkit.AjaxCommandRendererBase.doDecode(AjaxCommandRendererBase.java:59)
at org.richfaces.renderkit.RendererBase.decode(RendererBase.java:80)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:789)
at
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1183)
Truncated. see log file for complete stacktrace
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)