4 Replies Latest reply: Apr 29, 2012 9:07 AM by 610203 RSS

    Popup window in JSF

    933141
      Hi All,

      In Java EE Application i have created two JSF pages. When i click a button in first JSF, the second JSF page should appear in a pop up window. Is that possible.

      Let me also know how to add a pop up in JSF.

      Regards,
      Manickka.
        • 1. Re: Popup window in JSF
          gimbal2
          Opening a popup is a javascript/client side thing (window.open), not a JSF/server side thing. It is certainly possible, but often when you have a requirement to open a popup there are additional requirements in there that don't mesh well with the way that JSF works. So if you have to do more than only show a page in a popup, I'd be fully aware of the statefulness of JSF and how that works, to make sure you don't end up on very thin ice.
          • 2. Re: Popup window in JSF
            933141
            Hi,

            Thanks for the immediate response. I tried using window.open and i can see the second JSF page as a pop up. Now I am doing some additional operations in second JSF page. It is not displaying only text in that.

            Then let me know what is the best way to achieve it.
            • 3. Re: Popup window in JSF
              862919
              Hi Maanickka

              I've been using HTML layer instead of pop up window. Not sure whether it's your case, but in general it looks better.

              Moreover, you can use f:ajax when you need to perform operations on it.

              Regards,

              Henrique
              • 4. Re: Popup window in JSF
                610203
                In your case, If you really need a popup window I think that an option that will work is use a h:commandLink:

                - Use the onclick method of the h:commandLink to open a blank new page, with the name for example "blankPopUp".
                - Use a h:commandLink to navigate to the second page. The action method can be used to run a JSF navigation.
                - Use the target method of the command link to point to your window opened via javascript in the onclick event. In this case the target will be "blankPopUp". Then your content returned by the JSF navigation will be rendered in the already opened popup window. Then you will work with two windows, it will be like two tabs in your browser, but in this sample, only one will be a tab and another will be a popup window.

                Sample code:
                            <h:commandLink id="openPopUp" value="OPEN POPUP" target="blankPopUp" onclick="window.open('','blankPopUp','status=no,toolbar=no,location=no,menubar=no,resizable,width=1008,height=690,scrollbars,left=100,top=50');" action="#{yourBean.navigateToSecondPage}" />
                Regards.

                Edited by: kerule on 29-abr-2012 15:07