4 Replies Latest reply on Oct 14, 2008 9:16 PM by Eric H

    Specifying a filename for a PDF link on a web page

    Eric H Novice

      Simple question here.  I did use the search feature but didn't come up with anything helpful.

      I have links on my website to download PDFs.  Imagine something for printing invoices as PDFs.  The link should look like:


      It should then try to save itself with the filename of invoice-48949.pdf.  Of course that should come from a source link like:


      I tried to use URLRewrite to do this but I'm having no luck.

      Any suggestions on how to proceed on this?

      I don't know if this is complicating things, but I actually have two parameters, so it's more like:



        • 1. Re: Specifying a filename for a PDF link on a web page
          Eric H Novice

          Ok, the first problem was a regexp error.  That is fixed and there is a rule in place.  Now it's trying to fetch:


          and I'm getting:

          HTTP Status 404 - /seam-doc.seam

          Any ideas on that?  I feel like I'm getting closer to it.

          • 2. Re: Specifying a filename for a PDF link on a web page
            Eric H Novice

            And more info: this is the exception:

            18:42:06,366 WARN  [lifecycle] JSF1053: (Listener: org.jboss.seam.pdf.DocumentStorePhaseListener.beforePhase(), Phase ID: RENDER_RESPONSE 6,  View ID: /seam-doc.xhtml) Exception thrown during phase-listener execution: java.lang.NullPointerException
            18:42:06,370 WARN  [lifecycle] org.jboss.seam.pdf.DocumentStorePhaseListener.sendContent(DocumentStorePhaseListener.java:47)

            • 3. Re: Specifying a filename for a PDF link on a web page
              Eric H Novice

              I see the fundamental problem.  I'm using Seam 2.0.3CR1.  In that, looking at DocumentData.java:

                  public String getFileName() {
                      return getBaseName() + "." + getDocumentType().getExtension();

              whereas in 2.1CR1:

                  public String getFileName() {
                      if (fileName == null) {
                          return getBaseName() + "." + getDocumentType().getExtension();
                      } else {
                         return fileName;

              So obviously in 2.0, it's always going to return the basename + extension, which is exactly what I don't want to happen.

              I should either recompile 2.0 with the improved filename specification or I should switch to 2.1.  But this is an important production system so I don't want to switch in such haste.  I guess I'm going to try to re-compile 2.0.3CR1.  We're going to be generating tons of PDFs and if they all want to save as the same filename it will drive us crazy.

              • 4. Re: Specifying a filename for a PDF link on a web page
                Eric H Novice

                I just modified DocumentData.java and UIDocument.java to pass the filename along in the right way and it all works now, in Seam 2.0.3CR1.  Seam Team, you might consider putting this fix in for the 2.0.3 GA release, given that it's only a few lines and it's very relevant for almost any real-world use of PDF generation.  I would be happy to send over my changes but it's pretty trivial and obvious stuff.