5 Replies Latest reply on Apr 8, 2013 11:49 PM by 1001173

    Open in the same popup broswer window

      I have tried in JDev11. and JDev11.1.1.2.
      When the user click a button, first I want to do some actions, then launch a new broswer window (not a adf popup or dialog, just a new IE broswer window). If the user click the button again, i want to make sure I am using the same launched window. Below is the code:

      1) <af:commandButton text="Generate Document"

      2) In the action bean:
      public void CommandLink_Clicked(ActionEvent actionEvent) {

      // do something .................

      // launch/re-use same browser using javscript
      ExtendedRenderKitService erks =
      Service.getService(ctx.getRenderKit(), ExtendedRenderKitService.class);

      //this should make the url launch in the same window
      String url = "window.open('http://www.google.com','samewindow');";


      If the url is non-adf application url, such as: google.com, yahoo.com etc, everything would work as expected. However if the url is another adf appliction, such as: Then a new window would be launched each time, without reusing the same popup window. I could aslo reproduce this behavior using goLink, set targetFrame="same" destination="".

      Am I missing something? Is there a way to achieve the bahavior that I wanted?

        • 1. Re: Open in the same popup broswer window
          What about useWindow to true?
          • 2. Re: Open in the same popup broswer window
            Frank Nimphius-Oracle

            actually its this part of the code

            String url = "window.open('http://www.google.com','samewindow');";

            that doesn't work. You need to write a JavaScript function that exists on the page. Then when you call window.open, you store the window handle in JavaSCript variable. When you want to open another page in the same window you would then use the handle and just pass another URL to it. Note that if the browser does not spawn a new browser process, then invoking another JSF page may not have this being different from the one you actually run. However, you don't share a use case so I can't share a solution


            Edited by: Frank Nimphius on Feb 21, 2011 7:31 AM
            • 3. Re: Open in the same popup broswer window
              Thanks for the reply

              Actually the first thing I tried was writting the javascript function on the page, however that produced the same behavior as well. Since I reproduced the problem with af:goLink, may be I can explain better with this.

              Create a new jspx page, add a goLink to it

              Case 1:
              <af:goLink text="goLink" id="gl1" targetFrame="name"
              Behavior: user click on the link then new broswer opens with google site, user click on the link second time it will reuse the same popup browser for the google site again. So everything work as expected

              case 2:
              Change the destination to a adf application url, say you just created another page called test2.jspx
              <af:goLink text="goLink" id="gl1" targetFrame="name"
              Bahavior: first click opens new browser with test2.jspx, 2nd click will open another new browser for test2.jspx without reusing the opened browser.

              Basically I want case 2 to popup in the same window as well. Main thing is I don't understand why none-adf url works and adf url doesn't work
              • 4. Re: Open in the same popup broswer window
                Same issue here. Has some one resolved it?
                • 5. Re: Open in the same popup broswer window
                  When you specify the target (second parameter in window.open() or targetFrame for golink), you are giving that window a name, and this name is used to find the window so it can be reused. You can see the current window name by typing into your address bar:
                  javascript:alert("window name is: ("+window.name+")");

                  If you do it quick enough (before the document finishes loading), you can see the window is correctly named initially, but then gets changed to some randomly generated name (in this instance: "19f1n51cyc_1").

                  You can see where ADF is making this change by looking at the runtime source of the page (using <f12>) and searching the html for "window.name". ADF is defining an "onLoad" function:
                  <script type="text/javascript">AdfBootstrap._onLoad=function (){if (AdfPage.PAGE.__checkRichResponseDirty()) return;AdfIEAgent._userDataSessionToken = '8542362891999980579';var isCachedPage = AdfPage.PAGE.__handleCachedPageForNewWindow('19f1n51cyc_1');if (!isCachedPage){window.name='19f1n51cyc_1';}; ...

                  Note the last part of my snippit:
                  if (!isCachedPage){window.name='19f1n51cyc_1';};

                  One solution seems to be to rename the window back again. Some thing like:
                  <af:document id="myid">
                       <af:resource type="javascript">
                       function resetWindowName(event)
                            alert("window name is: ("+window.name+")");
                            alert("window changed back to: ("+window.name+")");
                       <af:clientListener type="load" method="resetWindowName"/>
                  This fixes the problem for me (the window is now reused), but the website I work on is used by a lot of people and I need to know how this might affect things.

                  Does anyone know why ADF is renaming the window? Are there any issues that may occur if I rename the window back again, as above?

                  Does anyone have a better solution (maybe changing an adf caching configuration item)?