Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Andreas S
Popup in Liferay 6
October 26, 2010 1:55 AM
Answer

Andreas S

Rank: New Member

Posts: 20

Join Date: October 26, 2010

Recent Posts

My popup code isn't working anymore in Liferay 6.

1var popup = Liferay.Popup({title:"Login",modal:true,width:400,center:true});
2jQuery(popup).load(url, {});


I searched a little and saw that jquery has been replaced by Alloy.

I checked Alloy and saw a dialog module which looked similar but when I took a look at the API I didn't see a way to use a url in the popup (just text in bodyContent).

Anyone have any ideas?
Jelmer Kuperus
RE: Popup in Liferay 6
October 26, 2010 9:18 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

 1
 2AUI().use('aui-dialog', function(A) {
 3   
 4        Liferay.YourPlugin = {
 5
 6            closePopup: function() {
 7                var instance = this;
 8
 9                var popup = instance._getPopup()
10
11                if (popup) {
12                    popup.hide();
13                }
14            },
15
16            displayPopup: function(url, title) {
17                var instance = this;
18
19                var popup = instance._getPopup();
20
21                popup.show();
22
23                popup.set('title', title);
24
25                popup.io.set('uri', url);
26                popup.io.start();
27            },
28
29            _getPopup: function() {
30                var instance = this;
31
32                if (!instance._popup) {
33                    instance._popup = new A.Dialog(
34                        {
35                            resizable: false,
36                            width: 600,
37                            xy: [15,15]
38                        }
39                    ).plug(
40                        A.Plugin.IO,
41                        {autoLoad: false}
42                    ).render();
43                }
44
45                return instance._popup;
46            }
47        }
48    }
49);



1Liferay.YourPlugin.displayPopup('/your/url');
Brahim TARNAOUI
RE: Popup in Liferay 6
January 12, 2011 9:53 AM
Answer

Brahim TARNAOUI

Rank: Junior Member

Posts: 64

Join Date: June 15, 2010

Recent Posts

Hi,


just i copy/paste your code, but is not executed.
can you explain me howto execute your code, if i will add some library or other.
and how can'i put the data in the popup using urlData attribute?

thx
ankit yakkundi
RE: Popup in Liferay 6
March 14, 2011 12:17 AM
Answer

ankit yakkundi

Rank: Regular Member

Posts: 221

Join Date: March 4, 2010

Recent Posts

hi..
can you please explain the steps which i need to follow to get the pop up portlet ie which files i need to use or change.
i want to create simple pop up when will be opened when a button is clicked from the portlet.

Thanks in advance..
Any idea or suggestions are welcome..
ankit yakkundi
RE: Popup in Liferay 6
March 16, 2011 2:23 AM
Answer

ankit yakkundi

Rank: Regular Member

Posts: 221

Join Date: March 4, 2010

Recent Posts

hi.
I am able to open the popup,but i wanted to know how can i give the url of the another portlet.for example if i have portlet called a-portlet and b-portlet in webapps.i want to open b-portlet as popup to a-portlet then i have url as "/b-portlet/view.jsp..

the popup shows "Failed to retrieve content".

Can you help me on this.

Any help or idea are welcome.
Thanks in advance.
Yan Naing Oo
RE: Popup in Liferay 6
June 29, 2011 2:42 AM
Answer

Yan Naing Oo

Rank: Regular Member

Posts: 180

Join Date: February 17, 2011

Recent Posts

jelmer kuperus:
 1
 2AUI().use('aui-dialog', function(A) {
 3   
 4        Liferay.YourPlugin = {
 5
 6            closePopup: function() {
 7                var instance = this;
 8
 9                var popup = instance._getPopup()
10
11                if (popup) {
12                    popup.hide();
13                }
14            },
15
16            displayPopup: function(url, title) {
17                var instance = this;
18
19                var popup = instance._getPopup();
20
21                popup.show();
22
23                popup.set('title', title);
24
25                popup.io.set('uri', url);
26                popup.io.start();
27            },
28
29            _getPopup: function() {
30                var instance = this;
31
32                if (!instance._popup) {
33                    instance._popup = new A.Dialog(
34                        {
35                            resizable: false,
36                            width: 600,
37                            xy: [15,15]
38                        }
39                    ).plug(
40                        A.Plugin.IO,
41                        {autoLoad: false}
42                    ).render();
43                }
44
45                return instance._popup;
46            }
47        }
48    }
49);



1Liferay.YourPlugin.displayPopup('/your/url');



Hi jelmer ,

If i want to to display when the home page is come out the popup will display. how can i do this ? could you please describe me by step ?

thanks
delang j
RE: Popup in Liferay 6
December 16, 2011 5:57 PM
Answer

delang j

Rank: Regular Member

Posts: 249

Join Date: July 13, 2008

Recent Posts

hi,
thanks for the code, right now it working fine in my custom portlet.
but new issue arise, how do i set position of pop up from top?
i did tried
1centered: true,

and
1xy: ['center',10]


but failed.
am i missing something.

below is my code
 1<portlet:renderURL var="suggestNewPlaceURL" windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>">
 2    <portlet:param name="jspPage" value="/suggest.jsp" />
 3</portlet:renderURL>
 4<%
 5    String newPopup = "Liferay.test.displayPopup('" + suggestNewPlaceURL.toString() + "');";
 6%>
 7
 8<aui:button-row>
 9    <aui:button onClick="<%= newPopup %>" value="suggest-new-place" />
10</aui:button-row>
11
12<script type="text/javascript">
13AUI().use('aui-dialog', function(A) {
14   
15    Liferay.test = {
16
17        closePopup: function() {
18            var instance = this;
19
20            var popup = instance._getPopup();
21
22            if (popup) {
23                popup.hide();
24            }
25        },
26
27        displayPopup: function(url) {
28            var instance = this;
29
30            var popup = instance._getPopup();
31
32            popup.show();
33            popup.io.set('uri', url);
34            popup.io.start();
35        },
36
37        _getPopup: function() {
38            var instance = this;
39
40            if (!instance._popup) {
41                instance._popup = new A.Dialog(
42                    {
43                        title: "suggest-new-place",
44                        resizable: false,
45                        centered: true,
46                        destroyOnClose: true,
47                        width: 600,
48                        xy: ['center',10]
49                    }
50                ).plug(
51                    A.Plugin.IO,
52                    {autoLoad: false}
53                ).render();
54            }
55
56            return instance._popup;
57        }
58    }
59});
60</script>


thanks.
Jelmer Kuperus
RE: Popup in Liferay 6
December 17, 2011 4:24 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

In my example code you see these lines :

1instance._popup = new A.Dialog(
2    {
3        resizable: false,
4        width: 600,
5        xy: [15,15]
6    }


if you change xy: [15,15] to centered: true it will center the dialog to the middle of the screen

if you change xy: [15,15] to align: { node: null, points: [A.WidgetPositionAlign.TC, A.WidgetPositionAlign.TC] } it will align the dialog to the top center of the screen
Enrique Ruiz (DiSiD)
RE: Popup in Liferay 6
February 10, 2012 12:20 AM
Answer

Enrique Ruiz (DiSiD)

Rank: New Member

Posts: 1

Join Date: September 11, 2007

Recent Posts

Hi all,

There is a little bug in jelmer's code, missing ;

Below the fix:

1closePopup: function() {
2                var instance = this;
3                var popup = instance._getPopup();


Regards
Danial Mustofa Habibi
RE: Popup in Liferay 6
March 18, 2012 8:00 AM
Answer

Danial Mustofa Habibi

Rank: Regular Member

Posts: 141

Join Date: November 1, 2011

Recent Posts

Hi there how To pass paramater between page ???in pop Up???
Mittal Patoliya
RE: Popup in Liferay 6
December 28, 2012 2:12 AM
Answer

Mittal Patoliya

Rank: New Member

Posts: 24

Join Date: December 14, 2011

Recent Posts

[quote=Enrique Ruiz (DiSiD)]Hi all,

There is a little bug in jelmer's code, missing ;

Below the fix:

1closePopup: function() {
2                var instance = this;
3                var popup = instance._getPopup();


Regards


I am facing one more problem popup gets appear only one time once I close pop up it does not appear again.
If I refresh the page and then click the button then only it appears second time.
Please let me know if you have any idea.
Jobin Mathew
RE: Popup in Liferay 6
August 28, 2014 3:28 AM
Answer

Jobin Mathew

Rank: Junior Member

Posts: 65

Join Date: July 4, 2014

Recent Posts

hi
i tried the same but no popup appears. and error in mozillla bowser as follows.
"TypeError: a.Dialog is not a constructor"
please help