problem to download files
bard123 May 15, 2008 3:29 PMHi,
I created a web application (client / server), where you can upload files from a client on a server, why, I use the component inputFile of icefaces. But I would like download the files that I have uploaded.
That is why I have created a button that lets them call the method download
Button:
<ice:panelGroup> <ice:commandButton value="Download" actionListener="#{ficheCreationDocument.download}"></ice:commandButton> </ice:panelGroup>
download method:
public void download(){ try { FacesContext context = FacesContext.getCurrentInstance(); ExternalContext ec = context.getExternalContext(); HttpServletResponse response = (HttpServletResponse) ec.getResponse(); response.reset(); response.setContentType("text/plain"); response.setHeader("Content-Disposition", "filename=persistence.doc"); response.setHeader("Content-Transfer-Encoding", "binary"); ServletOutputStream sop; sop = response.getOutputStream(); File fichier = new File("c:\\Yannick\\persistence.doc"); int taille = (int) fichier.length(); byte[] tableau = new byte[(int) fichier.length()]; FileInputStream in = new FileInputStream(fichier); in.read(tableau); sop.write(tableau); sop.flush(); context.responseComplete(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
But it does not work.
I have this error that appears with firebug :
[window.sync-connection] receive broadcast failed TypeError: _2e5.contentAsDOM() has no properties message=_2e5.contentAsDOM() has no properties
I don't know what is the problem ?
Thank you