Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Nicolas Hrbt
[6.1] closing Iframe login popup after successful login
11 de Outubro de 2012 00:33
Resposta

Nicolas Hrbt

Ranking: New Member

Mensagens: 6

Data de entrada: 2 de Agosto de 2012

Mensagens recentes

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
11 de Outubro de 2012 00:34
Resposta

Nicolas Hrbt

Ranking: New Member

Mensagens: 6

Data de entrada: 2 de Agosto de 2012

Mensagens recentes

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
11 de Outubro de 2012 01:27
Resposta

Oliver Bayer

Ranking: Liferay Master

Mensagens: 875

Data de entrada: 18 de Fevereiro de 2009

Mensagens recentes

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
9 de Junho de 2013 03:31
Resposta

Jignesh Majmudar

Ranking: Junior Member

Mensagens: 36

Data de entrada: 7 de Maio de 2010

Mensagens recentes

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
25 de Junho de 2013 07:03
Resposta

Rahul Rabhadiya

Ranking: Junior Member

Mensagens: 57

Data de entrada: 13 de Junho de 2013

Mensagens recentes

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
25 de Junho de 2013 07:31
Resposta

Laurent C

Ranking: New Member

Mensagens: 6

Data de entrada: 17 de Outubro de 2012

Mensagens recentes

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
26 de Junho de 2013 07:34
Resposta

Rahul Rabhadiya

Ranking: Junior Member

Mensagens: 57

Data de entrada: 13 de Junho de 2013

Mensagens recentes

Thank you very much .it is working . . it is really helpful. emoticon
Laurent C
RE: [6.1] closing Iframe login popup after successful login
26 de Junho de 2013 07:38
Resposta

Laurent C

Ranking: New Member

Mensagens: 6

Data de entrada: 17 de Outubro de 2012

Mensagens recentes

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
26 de Junho de 2013 11:55
Resposta

Shivam Aggarwal

Ranking: Junior Member

Mensagens: 55

Data de entrada: 17 de Janeiro de 2012

Mensagens recentes

Thanks a lot man!! works like anything