JavaScript error After cancel the file download popup window
Hi , I am trying to show Document download links in my ADF page. First time it is working file means i able to download linked document. But when I click again on same link to download page then i see only 0 byte file download and when i open the documen then it's showing
This page uses JavaScript and requires a JavaScript enabled browser.Your browser is not JavaScript enabled.I checked my browser setting and script in enabled...
Below is the ADF page and backing bean code....
<af:panelBox text="Pension FAQ's" id="pb1">
<af:table value="#{bindings.faqsTypeDocumentView1.collectionModel}"
var="row" contentDelivery="immediate" inlineStyle="height:300px;"
binding="#{fileDownloadBean.faqTable}"
rowSelection="single"
rows="#{bindings.faqsTypeDocumentView1.rangeSize}"
emptyText="#{bindings.faqsTypeDocumentView1.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings.faqsTypeDocumentView1.rangeSize}"
rowBandingInterval="0" id="t1">
<af:column
headerText="Document Name"
id="c1">
<af:commandLink text="#{row.DocName}" id="cl1" >
<af:fileDownloadActionListener filename="#{row.DocName}"
contentType="#{row.ContentType}"
method="#{fileDownloadBean.downloadFaq}"/>
</af:commandLink>
</af:column>
</af:table>
</af:panelBox>
public void downloadFaq(FacesContext context,
OutputStream out) throws IOException {
System.out.println(" file download clicked ................");
oracle.adfinternal.view.faces.model.binding.FacesCtrlHierNodeBinding rwData = (oracle.adfinternal.view.faces.model.binding.FacesCtrlHierNodeBinding)faqTable.getSelectedRowData();
Row row = rwData.getRow();
System.out.println(" Doc Id : "+ row.getAttribute("DocId"));
BlobDomain blob= (BlobDomain)row.getAttribute("Document");
long size= blob.getLength();
try{
InputStream is = blob.getInputStream();
byte[] buffer = new byte[(int)size];
int nread;
while ((nread = is.read(buffer)) != -1)
out.write(buffer, 0, nread);
}catch(IOException ioExp){
context.addMessage(null, new FacesMessage(" Not able to download file."));
ioExp.printStackTrace();
}
}