java - Primefaces Download File Which is Outside FacesContext -
i'm uploading excel workbook directory outside application context (for backup purposes) , saving path database.
now need download file , i'm trying use primefaces download, i'm getting null file.
here code (much primefaces showcase download section):
bean:
private streamedcontent file; public void download(arquivo arquivo) throws ioexception { inputstream stream = ((servletcontext)facescontext.getcurrentinstance() .getexternalcontext().getcontext()).getresourceasstream(arquivo.getnomearquivo()); file = new defaultstreamedcontent(stream); }
view:
<h:commandlink id="btndownload" title="download arquivo" actionlistener="#{arquivobean.download(obj)}"> <p:filedownload value="#{arquivobean.file}" /> </h:commandlink>
basically need pass external path inputstream instead of facescontext.
from see problem i'm passing application context inputstream, appending path in argument of getresourceasstream which, of course, not found.
i'm new filedownload thing. in advance!
Comments
Post a Comment