Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nicolas Hrbt
[6.1] closing Iframe login popup after successful login
October 11, 2012 12:33 AM
Answer

Nicolas Hrbt

Rank: New Member

Posts: 6

Join Date: August 2, 2012

Recent Posts

Hello,

I'm pretty new to liferay to sorry if this question is trivial.

I need to put the login in a popup iframe (so that the whole page is not reloaded if an action is triggered from the login - like forgot password or something)

So i successfully implemented the iframe popup simply by following the indications from http://www.liferay.com/community/wiki/-/wiki/Main/Using+Pop-up+in+Liferay by using some javascript on a button on my theme
 1AUI().ready("liferay-portlet-url","node", function(A) {
 2    Liferay.provide(window, 'showSignInPopup', function() {
 3        var instance = this;
 4
 5        var url = Liferay.PortletURL.createRenderURL();
 6        url.setPortletId("58");
 7        url.setWindowState("pop_up");
 8
 9        Liferay.Util.openWindow({
10            cache : false,
11            dialog : {
12                destroyOnClose : true,
13                align : Liferay.Util.Window.ALIGN_CENTER,
14                modal : true,
15                after : {
16                    render : function(event) {
17                        this.set('y', this.get('y') + 50);
18                    },
19                    destroy : function(event){
20                        window.location.reload();
21                    }
22                },
23                width : 500
24            },
25            dialogIframe : {
26                id : 'SignInPopupIframe',
27                uri : url.toString()
28            },
29            title : 'Sign-in',
30            uri : url.toString()
31        });
32    }, [ 'liferay-util-window' ]);
33
34    A.one(".login-button").on('click', function(e) {
35        showSignInPopup();
36    });
37   
38   
39});


However my problem is that I don't know how to close the popup after a successfull login, and I don't see any forum hint on how to do that, not mentionning the documentaion.

Can any one help? Thanks!
Nicolas Hrbt
RE: [6.1] closing Iframe login popup after successful login
October 11, 2012 12:34 AM
Answer

Nicolas Hrbt

Rank: New Member

Posts: 6

Join Date: August 2, 2012

Recent Posts

no one has a clue? is there something wrong / unclear with my question?
Oliver Bayer
RE: [6.1] closing Iframe login popup after successful login
October 11, 2012 1:27 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 867

Join Date: February 18, 2009

Recent Posts

Hi Nicolas,

I don't have a complete working solution for your problem but maybe you can use the following hints as a starting point. If you take a look at the way Liferay is handling popups you will maybe find a solution. I would use the "html \ portlet \ journal \ edit_article.jsp" and the javascript method "selectTemplate(...)" as a reference. The last parameter is the dialog object which is getting closed and the form submitted if the user confirms the popup message.

HTH Oli
Jignesh Majmudar
RE: [6.1] closing Iframe login popup after successful login
June 9, 2013 3:31 AM
Answer

Jignesh Majmudar

Rank: Junior Member

Posts: 36

Join Date: May 7, 2010

Recent Posts

Hi Nicolas,

Have you found any solution to close the popup after sign in?

I am facing the same issues.

please provide the solution if you or anybody have for the same.
Rahul Rabhadiya
RE: [6.1] closing Iframe login popup after successful login
June 25, 2013 7:03 AM
Answer

Rahul Rabhadiya

Rank: Junior Member

Posts: 57

Join Date: June 13, 2013

Recent Posts

I have same issue like you. Have u got any solution if yes then please help me .. emoticon
Laurent C
RE: [6.1] closing Iframe login popup after successful login
June 25, 2013 7:31 AM
Answer

Laurent C

Rank: New Member

Posts: 6

Join Date: October 17, 2012

Recent Posts

Hi,

We found a solution with Nicolas.

It's a little bit magic but :
  1. it works very well
  2. i can explain you how it works


We inject the pop-up at the theme level but i think you can do this at other place.

That's the code in our velocity template from the theme project.
 1
 2        #set($fast_login_id = "164") ## $PortletKeys.FAST_LOGIN
 3        #set($render_phase_value = "RENDER_PHASE") ## $PortletRequest.RENDER_PHASE
 4        #set($sign_in_url = $portletURLFactory.create($request, $fast_login_id , $themeDisplay.getPlid(), $render_phase_value))
 5        $sign_in_url.setWindowState("POP_UP")
 6        $sign_in_url.setPortletMode("VIEW")
 7        $sign_in_url.setParameter("saveLastPath", "0")
 8        $sign_in_url.setParameter("struts_action", "/login/login")
 9       
10        <script type="text/javascript">
11            // it will be used in the 2nd part.
12                        function _home_page_afterLogin(emailAddress, anonymousAccount) {
13                                window.location.reload(false);
14                        }
15
16                        // open pop-up containing the login form.
17            function signInDialog() {
18                window.namespace = '_home_page_';
19                window.randomNamespace = '_home_page_';
20                Liferay.Util.openWindow(
21                        {
22                            dialog: {
23                                centered: true,
24                                modal: true
25                            },
26                            id: '_home_page_signInDialog',
27                            title: Liferay.Language.get('sign-in'),
28                            uri: "$sign_in_url.toString()"
29                            }
30                        );
31                }
32        </script>   



How it works?

In fact, if you look at the file named html/portlet/login/login_redirect.jsp there is some script that call a method named ' randomNamespace + "afterLogin" '.
You can do what you want in this method (we use to avoid the page to be reloaded) and after calling this "afterLogin" method the popup is killed. To kill the pop-up there is a 'closeWindow' event that is fired by login_redirect.jsp with id param having ' namespace + "signInDialog" ' value. It's for that the pop-up is created with the id '_home_page_signInDialog'.

I hope it's help you.

Sorry if my explanation are not fully right, we do this a few months ago.

Laurent.
Rahul Rabhadiya
RE: [6.1] closing Iframe login popup after successful login
June 26, 2013 7:34 AM
Answer

Rahul Rabhadiya

Rank: Junior Member

Posts: 57

Join Date: June 13, 2013

Recent Posts

Thank you very much .it is working . . it is really helpful. emoticon
Laurent C
RE: [6.1] closing Iframe login popup after successful login
June 26, 2013 7:38 AM
Answer

Laurent C

Rank: New Member

Posts: 6

Join Date: October 17, 2012

Recent Posts

You're welcome.
I'm happy to be able to help someone on Liferay!
Shivam Aggarwal
RE: [6.1] closing Iframe login popup after successful login
June 26, 2013 11:55 AM
Answer

Shivam Aggarwal

Rank: Junior Member

Posts: 55

Join Date: January 17, 2012

Recent Posts

Thanks a lot man!! works like anything