1 Reply Latest reply on Mar 25, 2010 2:40 AM by Tim Evers

    generated pdf file contents are cached

    ehsmurali Newbie
         I am trying to publish the user information as a downloadable pdf file when clicked on a link(s:link) named print. Eveything works fine, the data pertaining to the clicked link get exported as pdf. However, the same information is published eventhough the user clicks on a different link.

         The report published for the first clinked link is getting cached for the subsequent links.

      Here is the code, that publishes the report.

      try {
              FacesContext facesContext = FacesContext.getCurrentInstance();
              Renderer renderer = Renderer.instance();

              DocumentStore store = DocumentStore.instance();
              DocumentData data = store.getDocumentData("1");
              HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
              String fileName = makeUniqueFileName();
              response.setHeader("Content-disposition", "attachment; filename=\"" +String.valueOf(new Random().nextInt())+ ".pdf"+"\"");
              response.setHeader("Pragma", "");

              ServletOutputStream os;
              try {
                      os = response.getOutputStream();
              } catch (Exception e) {
                      FacesMessages.instance().addFromResourceBundle( "reportCouldNotBeGenerated");

      } catch (Exception ex) {

        • 1. Re: generated pdf file contents are cached
          Tim Evers Master

          I'm sorry if this is really off base but,

          DocumentData data = store.getDocumentData("1");

          that looks pretty static to me as to which document is going to get returned. The documentStore is a conversation scoped component. So unless each link is in a brand new conversation then the I fail to see how using getDocumentData(1) is going to work.

          Hmm, been reading the code of DocumentStore a bit more. Can you post the code where you put the document into the store? Are you always doing store.saveData(1, document) ? If you are doing this then I'm not really sure. I can't see the documentStore doing anything fancy.

          Maybe try remotely debugging and see if your document is actually getting stored in the DocumentStore?