1 Reply Latest reply on Jun 20, 2013 6:17 AM by sivaprasad9394

    How to redirect from Java Bean to a new window or tab.

    sandy4you

      Hi All,

       

      I have a h:commandButton from where a action in the bean is callled and then I'm setting the external URL which I want to open like this:

      FacesContext.getCurrentInstance().getExternalContext().redirect("http://www.google.com");

      When the Action is complete i.e response is completed, the mentioned URL opens up but in the same window. I want to open it in a new window/tab.

      I also tried putting target="_Blank" to the h:commanButton but it did not work.

      Any suggestion.

       

      Regards,

      Sandy

        • 1. Re: How to redirect from Java Bean to a new window or tab.
          sivaprasad9394

          Try adding like ,

           

          <h:commandLink value="View" id="viewID1"

                          actionListener="#{docLibraryHome.loadViewImageListener}"

                          target="_blank" type="submit" style="text-decoration: none"/>

          Here actionListener will do the backing bean process and it will open in new window.

          you can also use ajax for it.