Hello, I posted a question previously relating to this that unfortunately has not had any replies - I'm hoping to get this resolved.... I have the same problem whereby the file's downloaded then any subsequent action on the page causes the file to re-download. I have added the saveSerializedView method but to no avail.
The action is triggered via a command link - now if I replace the command link with a command button this issue goes away; but I really don't want to use a button if I can help it! Can anybody help me with this please? Many thanks in advance, Carl Jeff Bischoff wrote: > > David, > > Thanks for the hint. Though I didn't ask the question, I have seen this > behavior on one or two of my pages. Now I'll have a chance to fix it > perhaps. > > Hmm... I went to the link your code points to, but there was really no > mention of *why* this solution works. Do you know who originally figured > this out or why it is necessary? I assume it's because we are skipping > some necessary lifecycle phase when we write to the out and then call > responseComplete? > > Regards, > > Jeff Bischoff > Kenneth L Kurz & Associates, Inc. > > David Chandler wrote: >> Simply add these two lines of code before the call to responseComplete(): >> >> // Save serialized view or else after clicking on the export >> button, >> user will have to click TWICE to invoke another action >> // See http://swforum.sun.com/jive/thread.jspa?threadID=63566 >> StateManager stateManager = (StateManager) facesContext >> .getApplication().getStateManager(); >> stateManager.saveSerializedView(facesContext); >> >> /dmc >> >> On 12/29/06, ::SammyRulez:: <[EMAIL PROTECTED]> wrote: >>> Hello and happy new year >>> >>> Im' using this action method to generate dynamicaly pdf file and send >>> them to the browser >>> >>> public String generaContratto(){ >>> FacesContext facesContext = FacesContext.getCurrentInstance(); >>> HttpServletResponse response = (HttpServletResponse) >>> facesContext.getExternalContext().getResponse(); >>> response.setContentType("application/pdf"); >>> String fileName = "blabla.pdf"; >>> response.setHeader("Content-disposition", " attachment; >>> filename=\"" + fileName + "\""); >>> try { >>> ServletOutputStream out; >>> out = response.getOutputStream(); >>> ProxyDaoFactory daoFactory = new ProxyDaoFactory(); >>> DocumentBuilder builder = new >>> DocumentBuilderWrapper(daoFactory, >>> facesContext.getExternalContext().getInitParameter("fileValut")); >>> builder.write(offerta,out); >>> >>> } catch (Exception e) { >>> ... >>> return "ERROR" >>> } >>> facesContext.responseComplete(); >>> >>> return "OK"; >>> } >>> >>> Everithing works fine: the pdf is generated, downloaded etc. >>> >>> But if I trigger some other action on the same view it just render the >>> page again.. I think it does render response phase. Model is not >>> updated. It act as if navigation (the ugly back button!) button where >>> used. >>> >>> Any ideas? >>> >>> -- >>> ::SammyRulez:: >>> http://www.kyub.com/blog/ >>> ----------------------------------------------------------------- >>> La programmazione รจ per un terzo interpretazione e per due terzi >>> ispirazione. >>> E per un terzo mistificazione >>> >> >> > > > > -- View this message in context: http://www.nabble.com/download-file-breaks-lifecycle-tf2893828.html#a8447914 Sent from the MyFaces - Users mailing list archive at Nabble.com.

