Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
6.7k views
in Technique[技术] by (71.8m points)

popup - Display portlet in pop-up Liferay

I am trying show a portlet (that previously I have created) from another one, but the pop-up is empty. First, I create the renderURL:

<liferay-portlet:renderURL var="testPopupURL" portletName="<%=rule.getBannerPortletId() %>" windowState="<%=LiferayWindowState.POP_UP.toString() %>"></liferay-portlet:renderURL>

and I do the link:

<aui:a href="#" onClick="showPopup('${testPopupURL}')">View</aui:a> 

and this is the function showPopup:

    function showPopup(url){
    console.log("En el showPopup ");
    AUI().ready('aui-dialog', 'aui-io', 'event', 'event-custom', function(A) {
        window.myDialog  = new A.Dialog({
            title: 'Banner',
            width: 640,
            centered: true
        }).plug(A.Plugin.DialogIframe, {
                uri: url.toString(),
                iframeCssClass: 'dialog-iframe'
        }).render();
    });
}

I put in the liferay-portlet.xml (of the portlet I want open in the pop-up) this:

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

The portlet is instanciable and the bannerPortletId is the porletId.

Any idea?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally I get display the portlet. I created the url with javascript:

    var url;
    function createRenderURL(portletId) {
    AUI().ready('liferay-portlet-url', function(A) {
        var renderURL = Liferay.PortletURL.createRenderURL();
        renderURL.setName("Banner");
        renderURL .setPortletMode("edit");
        renderURL .setWindowState("pop_up"); 
        renderURL.setPortletId(portletId);
    url = renderURL.toString();
    });
}

The code to show de pop-up is the same, but I pass the portletId like a parameter and call the function createRenderURL.

    var url;

function createRenderURL(portletId) {
    console.log("en el createRender");
    AUI().ready('liferay-portlet-url', function(A) {
        var renderURL = Liferay.PortletURL.createRenderURL();
        renderURL.setName("Banner");
        renderURL .setPortletMode("edit");
        renderURL .setWindowState("pop_up"); 
        renderURL.setPortletId(portletId);
        console.log(renderURL);
        url = renderURL.toString();
    });
}

I hope this can be useful for someone.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...