0 Replies Latest reply on May 15, 2008 3:29 PM by yannick bardon

    problem to download files

    yannick bardon Newbie


      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


               <ice:commandButton value="Download" actionListener="#{ficheCreationDocument.download}"></ice:commandButton>

      download method:

      public void download(){
                try {
                     FacesContext context = FacesContext.getCurrentInstance();
                     ExternalContext ec = context.getExternalContext();
                     HttpServletResponse response = (HttpServletResponse) ec.getResponse();
                     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);
                } catch (IOException e) {
                     // TODO Auto-generated catch block

      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