Hi All,
Jdeveloper version: 11.1.2.1.0
Use Case:
When user press the command button, system should retrieve PDF document from the database (BLOB file) and display on a new tab
Problem:
Managed to retrieve the file, but it replaces the current page rather than opening a new tab
I've tried few suggestions from below link, but still no luck:
-
2432385
- https://kr.forums.oracle.com/forums/thread.jspa?threadID=637676
My Code:
==============================================================
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
+// get an ADF attributevalue from the ADF page definitions+
AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("DsgnFileData");
if (attr == null)
+{+
return;
+}+
+// the value is a BlobDomain data type+
BlobDomain blob = (BlobDomain) attr.getInputValue();
try
+{+
ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
ServletOutputStream out = response.getOutputStream();
response.setHeader("Cache-Control", "max-age=0");
response.setHeader("Content-Disposition", "inline; filename=Report.pdf");
response.setContentType("application/pdf");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
IOUtils.copy(blob.getInputStream(), byteArrayOutputStream);
out.write(byteArrayOutputStream.toByteArray());
out.flush();
out.close();
FacesContext.getCurrentInstance().responseComplete();
+}+
catch (IOException e)
+{+
+// handle errors+
e.printStackTrace();
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), "");
FacesContext.getCurrentInstance().addMessage(null, msg);
+}+
==============================================================
Has anyone managed to do this? Help please
Thank you
Regards,
Andi