Java – the portlet URL opens another portlet in a pop-up window
I have a create_ account. JSP hook
The question is: how do I provide a portlet URL? How do I access it? In this portlet, I just want to ask a yes or no question and redirect to other pages according to the user's answer
Solution
>To create a URL, you can use < portlet: rendeurls > or < Liferay portlet: rendeurls >
<liferay-portlet:renderURL var="testPopupURL" portletName="testPopup_WAR_testPopupportlet" windowState="<%=LiferayWindowState.POP_UP.toString() %>"> <liferay-portlet:param name="paramToPopup" value="customParameterToThePortlet" /> </liferay-portlet:renderURL>
Portletname = "testpopup_war_testpopup Portlet" this is the portletid of the portlet you want to open
Windowstate = "<% = liferaywindowstate. Pop_up. Tostring()% >" this is very important for displaying the portlet in a pop-up window, otherwise it will open a complete Liferay page with navigation and all content. > You can write JavaScript in JSP to use the above URL and open pop-up windows and portlets in it:
// this is one of creating function function <portlet:namespace />showPopup(url) { var url = url; // this is one way of calling a pop-up in liferay // this way is specific to liferay Liferay.Util.openWindow( { dialog: { cache: false,width:800,modal: true },id: 'testPopupIdUnique',uri: url } ); } // this is another way of creating a function in liferay Liferay.provide( window,'<portlet:namespace />showAUIPopUP',function(url) { var A = AUI(); // this is another way of calling a iframe pop-up // this way is not specific to liferay popupDialog = new A.Dialog( { id: 'testPopupIdUnique',centered: true,draggable: true,resizable: true,width: 800,stack: true } ).plug( A.Plugin.DialogIframe,{ uri: url,iframeCssClass: 'ogilvy-dialog-iframe' } ); popupDialog.render(); },['aui-dialog','aui-dialog-iframe'] );
>You can simply call these JavaScript functions:
<a href="javascript:%20<portlet:namespace%20/>showPopup('<%=testPopupURL%>')"> Popup using Liferay open-window </a> <a href="javascript:%20<portlet:namespace%20/>showAUIPopUP('<%=testPopupURL%>')"> Pop-up using Alloy UI dialog </a>
>The portlet to be displayed in the iframe of the pop-up window should have < add default resource > true < / add default resource > in Liferay portlet In XML:
<portlet> <portlet-name>testPopup</portlet-name> <icon>/icon.png</icon> <instanceable>false</instanceable> <header-portlet-css>/css/main.css</header-portlet-css> <footer-portlet-javascript>/js/main.js</footer-portlet-javascript> <css-class-wrapper>testPopup-portlet</css-class-wrapper> <!-- This property is necessary otherwise you would see a "Access denied for portlet" message when you try to open this portlet dynamically --> <add-default-resource>true</add-default-resource> </portlet>
>Or you should add the property in portal-ext.properties to the portlet add. default. resource. check. Whitelist as:
portlet.add.default.resource.check.whitelist=3,56_INSTANCE_0000,58,82,86,87,88,103,113,145,164,166,170,177,testPopup_WAR_testPopupportlet
To see the actual operation of this code, you can download two portlets from it and refer to the instructions in this Liferay forum
I hope this helps to better understand Liferay