9 Replies Latest reply on Jan 20, 2011 8:18 AM by 809945

    how to create and call popup page from jsr168  portlet


      i have a webcenter application that's using a Portlet Producer template, then I created a jsr168 portlet page. This page has a hyperlink that's supposed to call a popup page. Is it possible for the portlet to call a popup page (and pass values to&from). Also, does the popup page need to be a portlet or any jspx will do?

      any input or reference is very much appreciated.

      thanks in advance,
        • 1. Re: how to create and call popup page from jsr168  portlet
          Yannick Ongena
          Are you using ADF portlets?

          That popup, does this need to be a new window or does it to be an af:popup?
          Normally when you want to open a popup window you only need to set the hyperlink: Link. You could also use the window.open command from javascript but this will be disabled by lots of popup blockers...

          Passing parameters can be easily done by adding them to the queryString of the URL in the href like this: href="yourPage.jspx?param1=yourValue&param2=otherValue"

          So as you can see, there are multiple ways of opening a popup so if you can tell what technique you want to use, we can give some more information or examples.
          • 2. Re: how to create and call popup page from jsr168  portlet
            Hi Yannick,

            Yes, I'm using ADF portlet. And this portlet has a link that should invoke a popup. not sure what does <af:popup> really means, but the requirement is the popup should contain detail info about the main page (thus, the value in our bean should also be displayed in the popup), the popup also has Save and Cancel button. Once Save is clicked,the main page should be refreshed. I think, the popup shouldn't be in a new window.

            what's the best practice when it comes to requirements like this?

            thanks a lot,
            • 3. Re: how to create and call popup page from jsr168  portlet
              Yannick Ongena
              Ah ok,
              So you want to have a master-detail view where the popup functions as the details of the selected item?

              For this you should use an af:popup with an af:dialog in it:

              When you are using ADF BC you can easily use the binding to bind the values for the inputText in the dialog to the selected item of a table or so.
              Are you using business component or how do you populate the list?

              Is this what you want? I can write a simple example to show this if you like but i need to be sure that this is your case...
              So in the portlet you select a value and in the popup you need to be able to alter the details of that record. Once saved, the portlet needs to be refreshed to show the new values. Is this correct?
              • 4. Re: how to create and call popup page from jsr168  portlet
                Thanks for the link, Yannick. I think the most applicable for our requirement is the popup on External Browser. Just a quick question, is it possible for a portlet page to call/invoke a popup "portlet" page? or only regular JSF page can be called in popup? Also, can a portlet invoke a popup page from a different application or the dialog page needs to be in the same application?

                thanks a lot!
                • 5. Re: how to create and call popup page from jsr168  portlet
                  Yannick Ongena
                  I don't think it's possible for a portlet to invoke a popup with a page from it's own portlet. I needs to be a page from te application. You can however use any page in the popup. You could also use google.com for example so it does not mind if it's an internal or external link.
                  Also, notice that when you call a page from another application and you need to be authenticated to that application before you can see the page you are invoking, then you need to setup some sort of SSO.
                  • 6. Re: how to create and call popup page from jsr168  portlet
                    i see. thanks Yannick.

                    Here's what I did, it's working a bit but i'm having problems pre-loading the popup
                    1. create an application using Portlet Producer template
                    2. create jsr168 portlet page (originating page)
                    - this has a commandLink that will invoke a popup in external browser
                    3. create a jspx page (dialog page)
                    - this page should contain some of the values from the originating page. I tried setting the launchListener to a method in my bean class (applicationScope) but the method seems not to be working,thus the values are not being pre-loaded.

                    do you have any idea why?

                    thanks again,
                    • 7. Re: how to create and call popup page from jsr168  portlet
                      Yannick Ongena
                      Don't know if i get it right...
                      Can you perhaps post the code on how you invoke the popup?

                      You are trying to execute a method from the launched JSPX that is a method of a managed bean in your portlet but has the applicationScope scope? Correct?
                      If this is the case than this will not work. By invoking the popup and JSPX, you are leaving the portlet context. That's why the managed bean is not doing anything in the jspx because it is not accessible.
                      • 8. Re: how to create and call popup page from jsr168  portlet
                        Hi Yannick,

                        yes, that's correct.

                        here's what i did

                        1. faces-config.xml - set managed bean and navigation rule
                            <!-- Originating Page -->
                            <!-- Navigation Case: Update -->
                        2. Portlet page has a commandLink that calls a launchListener method from ManagedBean before launching the dialog page
                        <af:commandLink text="Update" id="cl2"
                                                        action="dialog:updatePage" useWindow="true"
                                                        windowHeight="200" windowWidth="500">
                        3. Managed bean has a method that's being called by the launchListener, that calls another method that supposedly populates bean variables
                        // COde that will call pojo
                            public void handleLaunch(LaunchEvent event) {
                               //populate bean variables
                             // populate dialog variables
                              log.debug("handleLaunch end");
                        4. Dialog page (ordinary jspx page) has a component that should reference the variable from bean
                        <af:selectBooleanRadio id="sbr1"
                        Now, I ran the portlet page then I clicked the Update link. The dialog page pops-up but the launchListener method is not called, thus the bean variable is empty. Can you suggest a way wherein I can pre-load the dialog page, at the same time,retrieved the values from it?

                        thanks a lot,

                        I added actionListener to my commandLink that calls a method in the managed bean and it worked. the popup page is now pre-loaded. I noticed two problems- first -I just realized that my "dialog page" is not showing as popup,but more uses the same browser as the originating page. second - is that how can i programmatically close the "dialog page", it seems the returnFromDialog() is not working (perhaps because the dialog page is not rendered in a popup?)

                        Edited by: rian on Jan 20, 2011 12:33 PM
                        • 9. Re: how to create and call popup page from jsr168  portlet
                          i've been following the steps here http://download.oracle.com/docs/cd/E15051_01/web.1111/b31973/af_dialog.htm#BEJEDIBB section External Browser Popup Window but I can't seem to make it properly work.
                          -The dialog does not open in a popup window
                          -when I click Cancel button, error in popView is encountered when returnFromDialog() is encountered in the code.
                          - when I click Save button, error is again encountered when returnFromDialog() is encountered in the code. If I removed it, I don't know how to close the popup or to return to original page.

                          Please advise if I'm doing something wrong here (portlet invoking a popup jspx page).
                          I'm using JDev 11g, application template - Webcenter Portlet Producer

                          thanks again,