0
我正在使用jdev 11.1.1.5.0.
。在我的使用案例中,我想创建一个下载链接。当用户点击链接时,文件应该自动下载(如下载servlet)。如何在ADF中创建下载链接?
的代码如下:
HttpServletResponse response= (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); response.setContentType("text/plain"); response.setHeader("Content-Disposition","attachment;filename="+part.getFileName()); response.setContentType("text/plain"); response.setHeader("ContentDisposition","attachment;filename="+part.getFileName()); InputStreaminput=part.getInputStream(); int read=0;
byte[] bytes = new byte[1024]; OutputStream os =response.getOutputStream();
while((read=input.read(bytes))!=-1)
{os.write(bytes, 0, read);
}
os.flush();
os.close();
但它无法正常工作。我的要求是要创建动态链接(URL),并且当用户点击链接时,文件被下载。有没有其他方法可以做到这一点?谢谢。
嗨,实际上我有编程方式创建命令按钮并试图alose以下代码 –
RichCommandImageLink BT =新RichCommandImageLink(); bt.setText(“mybt”+ part.getFileName());MethodExpression returnMethodExpression = fileDownladActionListenerMethodExpression(“#{pageFlowScope.jagranmailclient.downloadAttachment}”); FileDownloadActionListener fileDownLoadListener = new FileDownloadActionListener(); fileDownLoadListener.setMethod(returnMethodExpression); fileDownLoadListener.setContentType(“plain/text”); fileDownLoadListener.setFilename(fileName); testbt.addActionListener(fileDownLoadListener); –