Opening portlet in popup

 

Sometimes, we may get requirements to open portlet in a popup. We can use below Javascrpit function to open in apopup.


AUI().use('aui-base','aui-component','aui-parse-content','aui-node','liferay-form',

    'liferay-portlet-url', 'liferay-util-window', 'plugin','aui-io-request', function(A){

        

          var renderURL = Liferay.PortletURL.createRenderURL();

      renderURL .setWindowState("exclusive"); 

      renderURL.setPortletId("<portlet-name>");

      var  url = renderURL.toString();


            A.io.request(url, {

                on: {

                 success: function(event, id, obj) {

                       var responseData = this.get('responseData');

                       if (responseData) {

                             Liferay.Util.openWindow({                                               

                                               dialog: {                                               

                                                   after: {

                                                       destroy: function(event) {

                                                       }

                                                   },

                                                   destroyOnHide: true,

                                               cache: false,

                                               centered: true,

                                               modal: true,

                                               resizable: false,                                               

                                                   'toolbars.header': [

                                                       {

                                                           cssClass: 'icon-close',

                                                           label: 'close ',

                                                           visible:true,

                                                           on: {

                                                               click: function() {

                                                                Liferay.Util.getWindow('popupId').destroy();

                                                               }

                                                           }

                                                       }

                                                   ],

                                               

                                               },

                                               id: 'popupId',

                                               title: 'This is title',

                                          },

                                         function(dialogWindow) {

                                               var bodyNode = dialogWindow.bodyNode;                 

                                               bodyNode.plug(A.Plugin.ParseContent);                 

                                               bodyNode.setContent(responseData);

                                         }

                                   );

                         }else{

// Else logic  

}

                },

                 failure: function() {

                 // failure logic

                 }

                }

           });

    });


This below code will ensure to execute the render method of a portlet to be open in the popup. 

 var renderURL = Liferay.PortletURL.createRenderURL();

      renderURL .setWindowState("exclusive"); 

      renderURL.setPortletId("<portlet-name>");

      var  url = renderURL.toString();


In renderURL.setPortletId() we need to input portletname.

Comments

  1. C'est un excellent tutoriel. Liferays offre des fonctionnalités étonnantes et nouvelles. Merci d'avoir partagé. Nous proposons également des services Liferay Java. Contactez-nous pour obtenir plus de détails

    ReplyDelete
  2. When done appropriately, opening a portlet in a popup can enhance usability. It enables users to concentrate on particular tasks without ever leaving the home page. However, as poorly designed popups can irritate users rather than improve the overall experience throughout modern web apps, performance, accessibility, and responsive behavior should be taken into account.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to know which liferay version we are using

Executing the BackGround Task

Order by Comparator