Keith,

Thanks for this tip.
I haven't experienced this behavior (svn Myfaces, facelets 1.0,
firefox 1.0.7, client-side state saving) even though I don't have this
line of code.

Can you explain that the problem is and why saveSerializedView() solves it?

I'd like to know if I'm going to be hit by it at some future point.

Also, some of the other myfaces committers were talking about creating
a download component, so it'd be good to know when we need to include
this code.

On 12/21/05, Keith Lynch <[EMAIL PROTECTED]> wrote:
> With the code above you'll run into a problem whereby on the page a click
> seems to be ignored after the download.
>
> Put this before responseComplete to fix things up.
>
> context.getApplication().getStateManager().saveSerializedView(context);
>
>
> On 12/19/05, Mike Kienenberger <[EMAIL PROTECTED] > wrote:
> > On 12/19/05, Anu Padki <[EMAIL PROTECTED]> wrote:
> > > Is it not possible to download a file using action method?
> > >  Do we have to write a servlet?
> >
> > Nope.  Here's how I do it.
> >
> >     public String downloadContentData()
> >     {
> >         Content selectedContent =
> > (Content)this.announcementContentDataList.getRowData();
> >         FacesContext facesContext = FacesContext.getCurrentInstance ();
> >
> >         try
> >         {
> >             OutputStream responseStream =
> >
> ((HttpServletResponse)facesContext.getExternalContext().getResponse()).getOutputStream();
> >
> >             HttpServletResponse response =
> >
> (HttpServletResponse)facesContext.getExternalContext().getResponse();
> >             response.setContentType(selectedContent.getContentType());
> >
> response.setHeader("Content-Disposition","attachment;filename=\""
> > + selectedContent.getContentId() + "\"");
> >
> response.setContentLength(selectedContent.getContentData().getData().length);
> >             responseStream.write(selectedContent.getContentData
> ().getData());
> >
> >             response.flushBuffer();
> >         }
> >         catch (IOException exception)
> >         {
> >             // TODO Auto-generated catch block
> >             exception.printStackTrace();
> >         }
> >
> >         facesContext.responseComplete();
> >
> >         return "downloadContentData";
> >     }
> >
>
>

Reply via email to