Blogs

Blogs

Portlet in Popup window in Liferay 6.2

Liferay 6.2 has  no longer supports the aui-dialog, aui-io etc,but all of them deprecated in 6.2. We need to use below mentioned AUI JS modules : 

http://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/alloyui-2-0-bootstrap-migration-liferay-portal-6-2-dev-guide-02-en

login_popup.jsp

<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>

<liferay-portlet:renderURL portletName="58" var="loginPortletURL"  windowState="<%=LiferayWindowState.POP_UP.toString()%>">
</liferay-portlet:renderURL>
 
<aui:button name="login-popup"  id="login-popup"  value="login"> </aui:button>
 <aui:script>
 AUI().use('aui-base','liferay-util-window','aui-io-plugin-deprecated',function(A){
 
  A.one('#<portlet:namespace/>login-popup').on('click', function(event){
  var login_popup= Liferay.Util.Window.getWindow(
                {
                    dialog: {
                        centered: true,
                        constrain2view: true,
                           modal: true,
                        resizable: false,
                        width: 475
                    }
                }).plug(A.Plugin.DialogIframe,
                     {
                     autoLoad: true,
                     iframeCssClass: 'dialog-iframe',
                     uri:'<%=loginPortletURL.toString()%>'
                     }).render();
            login_popup.show();
                     login_popup.titleNode.html("Login");
                    
 
  });
 });
 </aui:script>
   
aui-modal works almost like aui-dialog and aui-io-request like aui-io.
In case that you would like to use a new portlet (myPortlet) instead of Liferay’s portlet:

<liferay-portlet:renderURL portletName="myportlet_WAR_myportlet" var="myPortletURL"
windowState="<%=LiferayWindowState.POP_UP.toString()%>" portletMode="VIEW">

</liferay-portlet:renderURL>

<div>
<aui:button name="myportlet -popup" id="myportlet-popup" value="Open document for general user"> </aui:button>
</div>

<aui:script>
AUI().use('aui-base','liferay-util-window','aui-io-plugin-deprecated',function(A){

A.one('#<portlet:namespace/>login-popup').on('click',
function(event){

var my_popup= Liferay.Util.Window.getWindow(
{
dialog: {
centered: true,
constrain2view: true,
resizable: true
}
}).plug(A.Plugin.DialogIframe,
{
autoLoad: true,
iframeCssClass: 'dialog-iframe',
uri:'<%= myPortletURL.toString()%>'
}).render();
my_popup.show();
login_popup.titleNode.html("Windows title");
});
});
I addition that line should be in liferay-portlet.xml of myPortlet.

<add-default-resource>true</add-default-resource>