PortletURL 在弹出窗口中打开另一个 portlet [英] PortletURL to open another portlet in pop-up

查看:19
本文介绍了PortletURL 在弹出窗口中打开另一个 portlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 create_account.jsp 的钩子.在这个jsp中,我有一个javascript代码,我尝试在iframe弹出窗口或Liferay的一些弹出窗口中打开一个portlet.

I have a hook for create_account.jsp. In this jsp I have a javascript code where I try to open a portlet in an iframe pop-up or some pop-up from Liferay.

问题是:
如何给出portlet URL?
如何访问它?
在那个 portlet 中,我只想问一个是或否的问题,并根据用户的回答,重定向到其他页面.

The question is:
How to give the portlet URL?
How can I access it?
In that portlet I only want to ask a question with YES or NO, and based on the user answer, redirect to some other page.

推荐答案

  1. 要创建 URL,您可以使用 <portlet:renderURL><liferay-portlet:renderURL>

<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_testPopupportlet" 这是您要打开的 portlet 的 portletId.

portletName="testPopup_WAR_testPopupportlet" this is the portletId of the portlet which you want to open.

windowState="<%=LiferayWindowState.POP_UP.toString() %>" 仅在弹出窗口中显示 portlet 很重要,或者否则它将打开带有导航和所有功能的完整 Liferay 页面.

windowState="<%=LiferayWindowState.POP_UP.toString() %>" This is important to just show the portlet in the pop-up, or else it would open the full liferay pages with navigation and all.

您可以在 JSP 中编写的 javascript 使用上述 URL 并在其中打开弹出窗口和 portlet:

The javascript which you can write in your JSP to use the above URL and open the popup and the portlet within:

// 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']
);

  • 您可以像这样简单地调用这些 javascript 函数:

  • You can simply call these javascript functions something like this:

    <a href="javascript: <portlet:namespace />showPopup('<%=testPopupURL%>')">
        Popup using Liferay open-window
    </a>
    
    <a href="javascript: <portlet:namespace />showAUIPopUP('<%=testPopupURL%>')">
        Pop-up using Alloy UI dialog
    </a>
    

  • 将在弹出窗口的 iframe 内显示的 portlet 应该具有 <add-default-resource>true</add-default-resource>liferay-portlet.xml 中为:

  • The portlet which would be displayed inside the iframe of the pop-up either should have <add-default-resource>true</add-default-resource> in liferay-portlet.xml as:

    <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>
    

  • 或者应该在portal-ext.properties中有属性portlet.add.default.resource.check.whitelist为:

    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
    

  • 要查看此代码的实际运行情况,您可以从 下载 2 个 portlet 并参考其中的说明这个liferay论坛.

    To check out this code in action you can download 2 portlets from and refer to the instructions in this liferay forum.

    希望这有助于更好地理解 liferay.

    Hope this helps in understanding liferay better.

    这篇关于PortletURL 在弹出窗口中打开另一个 portlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆