myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthias Wessendorf" <mat...@apache.org>
Subject Re: File attachment - view state couldn't be restored, reload?
Date Thu, 21 Jun 2007 13:03:43 GMT
can you file a JIRA issue ?

On 6/21/07, Tathagat <mail@tathagat.com> wrote:
> FIXED.
> The problem was in the t:commandLink. if I use h:commandButton it works
> fine.
>
> Why, anyone has any idea?
>
> Cheers.
>
>
>
> On 6/21/07, Tathagat <mail@tathagat.com> wrote:
> >
> > Thanks Bruno.
> >
> > Now I do this.
> >
> _____________________________________________________________
> >    HttpServletResponse response =
> (HttpServletResponse)context.getExternalContext().getResponse();
> >    response.setHeader
> ("Content-Disposition","attachment;filename=\"mae.csv\"");
> >    response.setContentType("text/csv");
> >
> >    response.getOutputStream().write(sbExcel.toString().getBytes());
> >    response.getOutputStream().flush();
> >    response.getOutputStream ().close();
> >
> >    StateManager stateManager =
> (StateManager)context.getApplication().getStateManager();
> >    stateManager.saveSerializedView(context);
> >
> >    FacesContext.getCurrentInstance ().responseComplete();
> >
> _____________________________________________________________
> >
> > But I get an error - see attached image (image.jpg).
> >
> > Thanks in advance.
> >
> >
> >
> > On 6/21/07, Mikael Andersson <mail.micke@gmail.com > wrote:
> > > Thanks Bruno,
> > > will try that.
> > >
> > >
> > > PS.
> > > Hope Cambridge is treating you well :)
> > >
> > >
> > >
> > >
> > > On 21/06/07, Bruno Aranda < brunoaranda@gmail.com > wrote:
> > > > Hi,
> > > >
> > > > Before calling responseComplete(), that makes the lifecycle end, you
> > > > may need to save the state of the view by using the StateManager,
> > > >
> > > > StateManager stateManager = (StateManager)
> > > > faces.getApplication().getStateManager();
> > > > stateManager.saveSerializedView(faces);
> > > >
> > > > Calling it you save the component state information, used to restore
> the view...
> > > >
> > > > Hope it helps,
> > > >
> > > > Bruno
> > > >
> > > > PS. Mikael :-)
> > > >
> > > > On 21/06/07, Mikael Andersson <mail.micke@gmail.com > wrote:
> > > > > Hi
> > > > >
> > > > > I'm experiencing the same problem, and would also be interested in
> knowing
> > > > > if there are any solutions which don't involve bringing in another
> > > > > framework.
> > > > >
> > > > > If there isn't a solution, it would be great if someone could
> explain to me
> > > > > the reason why this happens.
> > > > > I think/guess it has something to do with the view state being build
> after
> > > > > render response, and by calling responseComplete that phase isn't
> invoked.
> > > > > Is that accurate?
> > > > >
> > > > > Cheers,
> > > > >  Mike
> > > > >
> > > > >
> > > > >  On 20/06/07, Tathagat < mail@tathagat.com> wrote:
> > > > > >
> > > > > > Hi all.
> > > > > > In my JSF application I have a link (t:commandLink) on click
of
> which I
> > > > > want to send an attachment to the user. The usual way in struts was
> > > > > >
> > > > > > snippet:
> > > > > > response.setHeader
> > > > >
> ("Content-Disposition","attachment;filename=\"mae.csv\ "");
> > > > > > response.setContentType("text/csv");
> > > > > > response.getOutputStream().write(file.getBytes()); // file is
some
> object
> > > > > which return bytes
> > > > > > response.getOutputStream ().flush();
> > > > > > response.getOutputStream().close();
> > > > > >
> > > > > > When I do this in JSF, I also do in the end:
> > > > > > FacesContext.getCurrentInstance().responseComplete();
> > > > > >
> > > > > > Works fine - But after I have the file, I try to do something
else
> > > > > (Another action), I get the error:View state couldn't be restored,
> reload?
> > > > > >
> > > > > > I guess it is because JSF loses the view (for some reason I
don't
> know).
> > > > > >
> > > > > > What is the right way to send an attachment to user with PURE
JSF
> > > > > solution.
> > > > > >
> > > > > > I read in some places about using shale, servlets, etc.. But
I
> want a pure
> > > > > JSF solution. Help, anyone?
> > > > > >
> > > > > > Thanks in advance.
> > > > > >
> > > > > > Cheers.
> > > > >
> > > > >
> > > >
> > >
> > >
> >
> >
> >
>
>


-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
mail: matzew-at-apache-dot-org

Mime
View raw message