9 Replies Latest reply on Dec 11, 2007 7:58 PM by supernovasoftware.com

    Submit form and open results in new window

    terryb

      guys I have a paid subscription but I don't seem to be getting any response to my seam questions there - hopefully someone can respond me here for this one.

      I have two pages (jsf/facelet); report-criteria.xhtml and report-pdf.xhtml. on report-criteria form I fill up few form fiends, and submit the form; then I would like report.pdf page to open up in a new window with query results utilising values on submitted page.

      I am not sure, how I can submit the form and open next page in new window utilising the values entered. I am not sure what to use, h:commandButton, h:commandLink, s:link, s:button or what?

      and do I must have a long running conversation here or, can it be done without it?



        • 1. Re: Submit form and open results in new window

          The links should all pass the target attribute through. For example:

          <s:link view="/whatever.xhtml" target="_blank" />
          





          • 2. Re: Submit form and open results in new window
            pettersonfp

            Hi,

            And if I want that my new window doesn't have menus?

            Thanks

            • 3. Re: Submit form and open results in new window

              I guess you'd have to use javascript to do that. I don't know which (if any) link tags support that.

              • 4. Re: Submit form and open results in new window
                pettersonfp

                Hi,

                That's what I feared :-)

                I hate javascript...

                Thanks

                Petterson

                • 5. Re: Submit form and open results in new window

                  I use something like the following to hide the browser menus.

                   <input id="index"
                   onclick="javascript:openNewWindow('/start.xhtml','appwin','status=yes,resizable=yes,toolbar=no,scrollbars=yes' + winCenterCoordinates(1024,768));window.opener=null;window.close();"
                   type="submit"
                   value="Enter" />
                  


                  Javascript
                  function openNewWindow(URLtoOpen, windowName, windowFeatures) {
                   newWindow = window.open(URLtoOpen, windowName, windowFeatures);
                  }
                  
                  function winCenterCoordinates(w, h) {
                   LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
                   TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
                   position = ',top = ' +TopPosition + ',left = ' +LeftPosition + ',height = ' +h + ',width = ' +w;
                   return position;
                  }
                  


                  Does anyone have any advice on opening then widow or not based on an Ajax request.

                  Currently I have a login form. This works normally. After successful login, the user is taken to a page with the button shown above. Here they click this button and a new window opens with the browser menus hidden.

                  I would prefer to give them a validation error if it fails and then open an new browser widow only if it is successful.

                  • 6. Re: Submit form and open results in new window
                    terryb

                    I may have misunderstood something but I think in my case I couldn't use s:link view="/whatever.xhtml" target="_blank" since it does not submit form. I wanted a single link to submit changes made to form fields and open second page in new window with query results based on submitted form.

                    I got it working with ...h:commandLink action="sb.action" target="_blank" and redirected to second page in .page.xml.

                    Peter, if you use facelets you could have 2 templates; with and without menu; and on the page in new window use the the one with no menus. That's how I do it.

                    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                     xmlns:s="http://jboss.com/products/seam/taglib"
                     xmlns:ui="http://java.sun.com/jsf/facelets"
                     xmlns:f="http://java.sun.com/jsf/core"
                     xmlns:h="http://java.sun.com/jsf/html"
                     xmlns:a4j="http://richfaces.org/a4j"
                     xmlns:rich="http://richfaces.org/rich"
                     template="#{something ? '/layout/template' : '/layout/template-nomenu'}">
                    


                    • 7. Re: Submit form and open results in new window
                      terryb

                      Jason thanks, browser menus of course.

                      • 8. Re: Submit form and open results in new window
                        pettersonfp

                        Jason that is exactly what I was needing,

                        Thanks a lot

                        P.S.: Terry, your idea is really good also. I 'll use it to solve another problem :-)


                        • 9. Re: Submit form and open results in new window

                          No problem. This forum is a life saver.

                          I guess I'll go as is the Richfaces forum if I get no answer here.