9 Replies Latest reply on Jul 11, 2008 9:18 AM by Ravi Shankar

    Portlet printing

    Grant Newbie

      I am trying to provide portlet print capability. Can anyone point me in the right direction? I tried renderResponse.createRenderURL() and opened the result in a javascript popup but it reproduces the page with all the tabs, header etc. I want just the portlet contents. Any help would be greatly appreciated!

        • 1. Re: Portlet printing
          Antoine Herzog Master

          What I would do is to define a new window state, such as the Maximized one, and make it work the same, but with a special layout and theme that is special for printing.

          see how it works for maximised window state. and adapt for a printing html page provided.
          You may need to add some things in the layout and theme, so the header etc does not show.


          • 2. Re: Portlet printing
            Grant Newbie

            I understand the first part but how would I accomplish the second part - "You may need to add some things in the layout and theme, so the header etc does not show"??

            • 3. Re: Portlet printing
              Antoine Herzog Master

              look how the layout and themes works.
              then play with the jsp to have your page with only the portlet content and may be a special light header.

              look at the file "portal-layouts.xml" in deploy/jboss-portal.sar/portal-core.war/WEB-INF
              and the other things about layout (the jsp files...) in this war.

              For a clean way, the best is to build a war that provide your new layout (the entire layout and themes for your portal).
              This to avoid to modify the jboss portal original file.
              In the default-object.xml, you define that your layout is "my_special_layout", and don't need anymore the orignal one.

              • 4. Re: Portlet printing
                Grant Newbie

                Antoine,

                Thank you for your assistance I have it all working now. I will post a thorough example (in the near future) step by step how to create the custom print mode and display a printer icon next to the edit one and have it open the portlet in maximized mode with no header just the portlet contents in another window, print and then automatically close the print window.

                • 5. Re: Portlet printing
                  Antoine Herzog Master

                  good !
                  you can write a wiki page.
                  it is an interesting feature.

                  in the wiki, there is a trick to create a new page :
                  - in the general page for portal : edit it and add your item
                  - the wiki server will then create this page and a link to modify it

                  • 6. Re: Portlet printing
                    Thomas Heute Master

                    Yes please the Wiki would help lot of other people :)

                    • 7. Re: Portlet printing
                      Allan Dewar Newbie

                      Hi Glarenzie

                      I would be very interested in seeing your solution as I am trying to achieve the same thing.

                      I am a JBoss portal newbie so I did not want to create my own layout on my first attempt.

                      Instead I modified the generic layout in portal-core.war/WEB-INF/portal-layouts.xml to include a uri state mapping to my custom layout jsp print.jsp.

                       <layout>
                       <name>generic</name>
                       <uri>/layouts/generic/index.jsp</uri>
                       <uri state="maximized">/layouts/generic/maximized.jsp</uri>
                       <uri state="print">/layouts/generic/print.jsp</uri>
                       <regions>
                       <region name="left"/>
                       <region name="center"/>
                       </regions>
                       </layout>
                      


                      I then also modified portal-core.war/WEB-INF/portlet.xml to include a custom window state called print as follows:

                      <custom-window-state>
                       <description>print view</description>
                       <window-state>print</window-state>
                       </custom-window-state>
                      


                      In my own portlet, when I switch the window state to print (via processAction) the layout is not mapped to print.jsp but to index.jsp. I'm clearly missing a step.

                      My new window state is being registered as when I obtain the PortalContext from the ActionRequest and then iterate over the supported window states, my custom state is included. I can't seem to map the layout to print.jsp however.

                      Help would be appreciated!

                      Regards

                      Allan

                      • 8. Re: Portlet printing
                        Antoine Herzog Master

                        Hello,

                        I don't see why it does not work : missing some practice to know "like that" exaclty what is missing".

                        what I would do is :
                        - put the print jsp url in the maximized state, just to see if this jsp is working.
                        - also put jsp temporary tags in the index.jsp, to check it is really the print state that is active when this page is wrongly used. I am quiet sure you have some tags and access to this information in the jsp.

                        well, some debug, to make sure the window state is print, the jsp is seen, etc...

                        hope it helps

                        • 9. Re: Portlet printing
                          Ravi Shankar Newbie

                          Hi ,
                          Can anyone give a thorough example that solves the mentioned problem, the print capability in portlet.