File attachment using Adf faces, EJB3 and Oracle XE database Part IV
continued... Downloading file In download button, add FileDownloadActionListener and select fileDownloadActionListener from backingBean The binding of attachment page should looks like above. Following is the code in AttachmentBackingBean public void downloadAction(FacesContext facesContext, OutputStream outputStream) { Attachment att = (Attachment)attachmentList.getSelectedRowData(); ExternalContext ectx = facesContext.getExternalContext(); String fileName = null; byte[] contents = null; if (att == null) { return; } else if (att.getAttachmentId() == null) { fileName = att.getFileName(); contents = att.getFileContent(); } else { OperationBinding oper = getBindings().getOperationBinding("findAttachmentById"); oper.getParamsMap().put("attachmentId", att.getAttachmentId()); Attachment attachment = (Attachment)oper.execute(); fileName = attachment.getFileName(); contents = ...