3 Replies Latest reply on Sep 14, 2009 10:13 AM by lvdberg

    How to serve some static PDF-files with enabled DocumentStoreServlet?

    gena

      Hello, since i've enabled the DocumentStoreServlet, i can not serve the pdf files directly from a folder. I understand, why it is so (seam docu says:  "This capability requires some configuration. To serve PDF files, all *.pdf resources should be mapped to the DocumentStoreServlet:"), but i hope, there is a solution for such simple problem.


      Many thanks, Gena

        • 1. Re: How to serve some static PDF-files with enabled DocumentStoreServlet?
          wassenama

          I have this very same issue...hoping someone has an answer.

          • 2. Re: How to serve some static PDF-files with enabled DocumentStoreServlet?
            ludgertheile

            I got a solution by overriding the Method
                 


            protected String baseUrlForContent(String baseName, String extension)



            of the DocumentStore




            import org.jboss.seam.ScopeType;
            import org.jboss.seam.annotations.Install;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.Scope;
            import org.jboss.seam.document.DocumentStore;
            
            @Name("org.jboss.seam.document.documentStore")
            @Scope(ScopeType.CONVERSATION)
            @Install(precedence = Install.APPLICATION)
            public class SdispoDocumentStore extends DocumentStore {
            
                 private static final long serialVersionUID = 8127699198478477789L;
            
                 @Override
                 protected String baseUrlForContent(String baseName, String extension) {
                      String baseUrl = "generated/" + super.baseUrlForContent(baseName, extension);
                      return baseUrl;
                 }
            }
            




            And in web.xml:




               ...
               <!-- Seam PDF Documents -->
            
               <servlet>
                  <servlet-name>Document Store Servlet</servlet-name>
                  <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
               </servlet>
               
               <servlet-mapping>
                  <servlet-name>Document Store Servlet</servlet-name>
                  <url-pattern>/generated/*</url-pattern>
               </servlet-mapping>
               ...
            




            But, it whould be nice to do this only by configuration.


            • 3. Re: How to serve some static PDF-files with enabled DocumentStoreServlet?
              lvdberg

              Maybe you should use the s:download or s:resource tags ?