10 Replies Latest reply on Mar 9, 2010 8:13 PM by Sarat Kumar

    SEAM PDF

    Sarat Kumar Newbie

      PLease share a example of rendering PDF using RENDERER.render(...) API

        • 1. Re: SEAM PDF
          Arbi Sookazian Master

          According to the Seam API doc:



          A component for direct rendering of templates. Especially useful with Seam Mail.

          http://docs.jboss.org/seam/2.2.0.GA/api/org/jboss/seam/faces/Renderer.html


          What is the problem you're trying to solve?  See the itext example in distro for PDF stuff.

          • 2. Re: SEAM PDF
            Sarat Kumar Newbie
            Is there any way to render the .xhtml (pdf template) in seam .
            (Case here is we are not using JSF )


            Below is my code
            //Purpose this method is to generate report in PDF & return the search results
            public List<Address> searchAddress(SearchVO searchVO) {
                      
                      String query = generateQuery(searchVO);
                      log.info(" JPA QL = " + query);
                      log.info(searchVO );
                      Query emQuery = entityManager.createQuery(query);
                      List<Address> lsit=emQuery.getResultList();
                      
                         System.out.println("Size ....... "+list.size());
                      Contexts.getEventContext().set("pdfDatas", list);
                      Renderer.instance().render("/pdf/pdf.xhtml");
                      return list;
                 }



            But the above method doesnot render the PDF view .
            • 3. Re: SEAM PDF
              Arbi Sookazian Master

              I'm not sure, I've never tried, but try modifying the itext example to use your API call as a test:


              Renderer.instance().render("/pdf/pdf.xhtml");


              from org.jboss.seam.example.mail.MailExample class:


              @In
                 private Renderer renderer;
              
              public void send() {
                    try {
                      renderer.render("/pdf/pdf.xhtml");
                      facesMessages.add("Email sent successfully");
                    } catch (Exception e) {
                       log.error("Error sending mail", e);
                       facesMessages.add(FacesMessage.SEVERITY_INFO, "Email sending failed: " + e.getMessage());
                    }
                 }

              • 4. Re: SEAM PDF
                Arbi Sookazian Master

                I just viewed the source code for the org.jboss.seam.faces.Renderer class and it's an abstract class:


                @Name("org.jboss.seam.faces.renderer")
                @Install(false)
                public abstract class Renderer
                {
                    public abstract String render(String viewId);
                    
                    public static Renderer instance()
                    {
                        return (Renderer) Component.getInstance(Renderer.class);
                    }
                }



                But I found no class that extends this one.  So I don't understand during runtime how there's an implementation of the render method above for the Renderer instance?

                • 5. Re: SEAM PDF
                  Sarat Kumar Newbie

                  SO is there any way to render a PDF file in seam ( with out using JSF )

                  • 6. Re: SEAM PDF
                    Arbi Sookazian Master

                    I honestly don't know but it would be nice if the Seam core dev team answered these questions once in a while like the JBoss Tools core guys, or the RichFaces core guys or the Spring core guys or the JRebel team (or pretty much the rest of the frmwk dev world).


                    What the hell is going on with this core dev team?  What a disaster!

                    • 7. Re: SEAM PDF
                      Radu B Newbie

                      You will find a lot of examples by just using the search capabilities of this forum.
                      A nice post is


                      http://seamframework.org/Community/PDFdocumentStore


                      @Arbi, I'm subscribed to this forum for about 11 Month and I have more that 16000 emails with reply's and questions.
                      If you ask me, I prefer to get answers from other users with similar experience. I don't see how we can get soon a new version of Seam while core developers reply to questions of basic usage...

                      • 8. Re: SEAM PDF
                        Arbi Sookazian Master

                        Then how are the other core dev teams doing it?  I typically get 24hr responses from Max Andersen and his team for JBT questions, likewise from RichFaces.  They all work for the same company JBoss, including the Seam core dev team.  Now Seam core has a new guy but one left.  Perhaps Redhat should hire more engineers?


                        zeroturnaround has a support team that responds to my emails while I was testing JRebel 3-M2.  Why can't JBoss do something similar?  Well they do but it's with a paid developer subscription.

                        • 9. Re: SEAM PDF
                          Ronald van Kuijk Apprentice

                          (reply on the real content later)


                          Or the jBPM core guys... But in reality. I do not like all this complaining. I know from the inside (jBPM) that there can be many issues that need to be taken care off, varying from technical via commercial to political and everything in between (WELD, CDI anyone?). So please let's not rant since they at least gave us this great framework.


                          Now to the real question which is a little weird. Sure it is possible to render the pdf without jsf... use plain IText or xhtmlrenderer by Sun Oracle but getting values from seam components into the plain xhtml is up to you...


                          The templates are Facelets so you need that. At least not with the xhtml files you'd create with seam. The answer to this question is very simple in the great docs, so I'm not really surprised the core devs do not answer this. From the FIRST paragraph of the Seam iText docs



                          iText support is provided by jboss-seam-pdf.jar. This JAR contains the iText JSF controls, which are used to construct views that can render to PDF, and the DocumentStore component, which serves the rendered documents to the user. To include PDF support in your application, put jboss-seam-pdf.jar in your WEB-INF/lib directory along with the iText JAR file. There is no further configuration needed to use Seam's iText support.

                           


                          The Seam iText module requires the use of Facelets as the view technology. Future versions of the library may also support the use of JSP. Additionally, it requires the use of the seam-ui package.

                          So....

                          • 10. Re: SEAM PDF
                            Sarat Kumar Newbie

                            Thanks Ronald,Arbi and Radu  for your suggestions .....



                            So here is what we conclude :
                            a) Seam can not render the PDF files without using JSF controls . ( can use normal Itext or some other features to do so .. )
                            b) We can use the workaround provided by Radu for generating the PDF files


                            Correct me if I am wrong .


                            -Sarat