0
votes

I am facing issue with opening a custom portlet in popup window.

Below is the code of opening popup.

LiferayPortletURL documentLibURL = PortletURLFactoryUtil.create(request, "portlet name with WAR name", themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);   
documentLibURL.setWindowState(LiferayWindowState.POP_UP);   
documentLibURL.setPortletMode(PortletMode.VIEW);

  AUI().use('aui-dialog', 'aui-io', 'event', 'event-custom', function(A) {
        var dialog = new A.Dialog({
                width: 800,
                height: 500,
                title: 'Popup Title',
                centered: true,
                draggable: true,
                modal: true
            }).plug(A.Plugin.IO, {uri: '<%= documentLibURL.toString() %>'}).render();

            dialog.show();

      });

When my portlet is not having any call to local services, portlet is being rendered in popup. But after adding some complex code. Portlet is giving permission error. "You do not have the roles required to access this portlet."

1) I have also added true in liferay-portlet.xml.

2) I have assigned permissions to guest user for view from control panel.

Please let me know if any changes requires.

Thanks in advance

3
I was working on that till now. I get to know that. If I am not adding my portlet on any page, this error is coming. Once I add my portlet to some page. Portlet is also being rendered in the popup. It is something like Liferay is not getting any instance of portlet. Let me know if there is any solution to that.hardik.rajani

3 Answers

1
votes

Local service calls will never generate a permission exception (PrincipalException) but remove services will.

Audit your code that this URL will invoke and see if there are any remove service calls. They are easily distinguished. For example, if it is the User service you're working with a call to UserLocalServiceUtil will never throw a PrincipalException but a call to UserServiceUtil will. Check to see what calls you're making to *ServiceUtil and ensure the user performing the operation has sufficient access.

0
votes

Which version of liferay your using.
The dialog will not work in liferay 6.2 and also maybe in 6.1, refer the below code.

 function popup(url){

 AUI().ready(function(A) {
    AUI().use('aui-base', function(A) {
        Liferay.Util.Window.getWindow(
            {
                title : "Popup Tile",
                uri: url,
                dialog: {
                    cache: false,
                    modal: true
                }
            }
        ).on('hide', function() {
              console.log("Modal closed")});

    });
});
}

if its correct dont forget to mark it as an answer

0
votes

just add in your portal-ext.properties the following code and restart the server

layout.show.portlet.access.denied=false