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



--
David Chandler
Development Coach
learnjsf.com

Reply via email to