Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

fileDownloadActionListener download PDF file in ADF 11

Reena MehtaSep 24 2009 — edited Sep 27 2009
Hi ,

I have a requirement to download the PDF file on the file system. I am using fileDownloadActionListener . I am using the following code .

<af:commandLink text="Download the stored PDF">
<af:fileDownloadActionListener filename="#{row.FirstName}.pdf"
contentType="application/pdf;charset=UTF-8"
method="#{FindReports.reportPDFDownload}"/>
</af:commandLink>

Managed bean code

public void reportPDFDownload(FacesContext facesContext,
OutputStream outputStream) throws IOException {
OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
InputStream in = getReportDocument(); // fetch the data from DB
System.out.println("input file is :" + in);
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int length;
while ((length = in.read(buffer)) > 0) {
w.write(buffer.toString());
}
w.flush();
w.close();
}


When I open the downloaded file , it says file corrupted or not correctly decoded. I checked the downloaded file size, it's 10 bytes.

Could any one suggest me how to resolve the issue ?

Thanks,
Reena
This post has been answered by 619264 on Sep 25 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2009
Added on Sep 24 2009
2 comments
2,941 views