Thanks to you for the opportunity to colaborate :-)

with the help of: CD

 --- Matthias Wessendorf <[EMAIL PROTECTED]> escribió:

> I saw the entry
> 
> thanks!
> 
> http://tinyurl.com/oae4a
> 
> On 6/12/06, Johnny Gonzalez
> <[EMAIL PROTECTED]> wrote:
> > Hello Matthias,
> >
> > I submitted the change to the wiki, but it still
> > doesn't appear, does it have to pass an
> authorisation
> > phase before appearing in the wiki??
> >
> > Thanks a lot,
> >
> > Johnny
> >  --- Matthias Wessendorf <[EMAIL PROTECTED]>
> escribió:
> >
> > > easy to create a password (use the login link)
> > >
> > > added to
> > >
> > > "JSF and MyFaces in Praxis: Specialized Trails"
> > >
> > > and create a subtitle like "sending files (like
> PDF)
> > > to the browser"
> > >
> > > something like that.
> > >
> > >
> > >
> > > On 6/12/06, Johnny Gonzalez
> > > <[EMAIL PROTECTED]> wrote:
> > > > Hello Matthias,
> > > >
> > > > I'd like to, but I have no idea where to put
> it on
> > > the
> > > > wiki, Where do you recommend me to post it?
> > > >
> > > > Do I need a password for doing so?
> > > >
> > > > Thanks a lot,
> > > > Johnny
> > > >  --- Matthias Wessendorf <[EMAIL PROTECTED]>
> > > escribió:
> > > >
> > > > > Johnny,
> > > > >
> > > > > this has been asked a lot. So since you got
> a
> > > nice
> > > > > hint,
> > > > > can you bring it to our wiki page ([1]).
> > > > >
> > > > > Would be great!
> > > > >
> > > > > Thx,
> > > > > Matthias
> > > > >
> > > > > [1] http://wiki.apache.org/myfaces
> > > > >
> > > > > On 6/12/06, Johnny Gonzalez
> > > > > <[EMAIL PROTECTED]> wrote:
> > > > > > Hello CD,
> > > > > >
> > > > > > Thanks a lot, that worked perfect :-D
> > > > > >
> > > > > > Johnny
> > > > > >  --- CD <[EMAIL PROTECTED]> escribió:
> > > > > >
> > > > > > > Johnny,
> > > > > > >
> > > > > > > Try setting the header for the response:
> > > > > > >
> > > > > > >
> response.setHeader("Content-disposition",
> > > > > > > "attachment; filename="+filename);
> > > > > > >
> > > > > > > Regards,
> > > > > > > CD
> > > > > > >
> > > > > > >
> > > > > > > On 6/12/06, Johnny Gonzalez
> > > > > > > <[EMAIL PROTECTED]> wrote:
> > > > > > > >
> > > > > > > > Hello everybody,
> > > > > > > >
> > > > > > > > I have to send a file to the response
> for
> > > the
> > > > > > > browser
> > > > > > > > to show a save/open file dialog box to
> the
> > > > > user,
> > > > > > > so
> > > > > > > > he/she can download it and save in in
> > > his/her
> > > > > > > local
> > > > > > > > file system. As expected the file is
> > > stored in
> > > > > a
> > > > > > > > specific directory in the file system
> of
> > > the
> > > > > > > server.
> > > > > > > >
> > > > > > > > What I did was to call this method
> within
> > > a
> > > > > > > > commandLink component:
> > > > > > > >
> > > > > > > > public String downloadDB(){
> > > > > > > >      FacesContext context =
> > > > > > > > FacesContext.getCurrentInstance();
> > > > > > > >
> > > > > > > >      HttpServletRequest request = (
> > > > > > > > HttpServletRequest )
> > > > > > > >
> > > > > > > >
> context.getExternalContext().getRequest(
> > > );
> > > > > > > >      HttpServletResponse response =
> > > > > > > >         ( HttpServletResponse )
> > > > > > > >
> > > context.getExternalContext().getResponse();
> > > > > > > >
> > > > > > > >      String filePath = null;
> > > > > > > >      int read = 0;
> > > > > > > >      byte[] bytes = new byte[1024];
> > > > > > > >
> > > > > > > >      filePath = getMyDBPath();
> > > > > > > >
> > > > > > > >
> > > > > response.setContentType("application/pdf");
> > > > > > > >      FileInputStream fis = null;
> > > > > > > >      OutputStream os = null;
> > > > > > > >
> > > > > > > >      try {
> > > > > > > >         fis = new FileInputStream(new
> > > > > > > > File(filePath));
> > > > > > > >         os =
> response.getOutputStream();
> > > > > > > >         while((read = fis.read(bytes))
> !=
> > > -1){
> > > > > > > >            os.write(bytes,0,read);
> > > > > > > >         }
> > > > > > > >         os.flush();
> > > > > > > >         os.close();
> > > > > > > >      }
> > > > > > > >      catch ( FileNotFoundException e1
> ) {
> > > > > > > >         logger.error(e1);
> > > > > > > >         logger.info(e1.getMessage());
> > > > > > > >         request.setAttribute("errors",
> > > "File
> > > > > Not
> > > > > > > > Found.");
> > > > > > > >      }
> > > > > > > >      catch ( IOException ioe ) {
> > > > > > > >         logger.error(ioe);
> > > > > > > >         logger.info(ioe.getMessage());
> > > > > > > >         request.setAttribute("errors",
> > > "Error
> > > > > > > reading
> > > > > > > > file.");
> > > > > > > >      }
> > > > > > > >      return "";
> > > > > > > >   }
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > After the user clicks on the
> commandLink,
> > > the
> > > > > page
> > > > > > > I'm
> > > > > > > > working on, gets refreshed and at the
> top
> > > of
> > > > > it
> > > > > > > > appears the text of the file I tried
> to
> > > > > download.
> > > > > > > This
> > > > > > > > is not the expected behaviour, what
> should
> > > I
> > > > > do?
> > > > > > > >
> > > > > > > > thanks a lot,
> > > > > > > > Johnny
> > > > > > > >
> > > > > > > >
> > > > >
> > >
> __________________________________________________
> 
=== message truncated ===


__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam
¡gratis! 
Regístrate ya - http://correo.yahoo.es 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.es 

Reply via email to