2 Replies Latest reply on Aug 20, 2010 12:32 PM by Fabin Riako

    New window and naviagtion from s:link

    Fabin Riako Newbie

      Hi All,


      I have a s:link to open a pdf in a new window. It is working fine, but when I click on the link actually I need two things to happen.


      1 It should open a new window to display the PDF
      2 The actual page in which the s:link is displayed should go to a new page(I mean the actual page).


      Now I have a link to show the pdf and a button just for navigate to another page. I need to avoid user clicking on the button to move to next page.


      Anybody knows how I can do this.


      Advanced Thanks

        • 1. Re: New window and naviagtion from s:link
          Daniel Rowe Newbie
          You might try opening the new PDF window with a javascript function invoked by using "onclick" in the s:link, and then doing normal navigation from the s:link to get to your new page.

          Something like this:

          |<s:lin|k value="Show PDF" onclick="startPDF(#{pdf.id}); return true" action="some_action_that_take_you_to_new_page"/>

          Depending on how you can access your pdf, you may have to use some Seam remoting (or maybe you can do it more simply in a single javascript function -- I'm not sure).  Here is the remoting way I've used for something similar:

          <s:remote include="PDFManager"/>
             
          <script>
          <!--
          function startPDF(pdfId){
             var pdfManager = Seam.Component.getInstance("PDFManager");
            
             pdfManager.setPDF(pdfId,popupPDFWindow);
          }

          function popupPDFWindow(){
             var cmd = '/gbmdrc/pdfWindow.seam';
             window.open(cmd,'PDF','toolbar=0,modal=1,dialog=1,scrollbars=1,alwaysRaised=1,width=840,height=480,resizable=1');
          }
          // -->
          </script>

          In your manager bean:

          public void setPDF(Long pdfId) {
             // Do something in here to allow pdfWindow.xhtml to get at the rendered ||PDF file
          }

          Hope this helps!