How can I open a pop up of my JSF portlet's edit mode?

假装没事ソ 提交于 2019-12-19 10:47:12

问题


When opening the configuration mode of a Liferay portlet it opens in a pop up dialog:

How can I get my JSF portlet to open a similar pop up but for edit mode of my JSF portlet?

I am using Liferay 6.2.


回答1:


In Liferay 6.2+:

For the most part, you can open edit mode of a JSF portlet the same way for both JSF and JSP portlets: via the client-side JS Liferay.Util.Window.getWindow() method. To create the dialog, you will need to get a render URL for the portlet in edit mode and pop up state via portlet:renderURL:

<portlet:renderURL var="popUpEditModeURL" escapeXml="false"
    portletMode="edit" windowState="pop_up" />

Then use the URL in the Liferay.Util.Window.getWindow() method:

<h:outputScript>
    AUI().use('liferay-util-window', function(A) {
        var popUp = Liferay.Util.Window.getWindow({
            dialog: {
                centered: true,
                constrain2view: true,
                resizable: false
            }
        }).plug(A.Plugin.DialogIframe, {
            autoLoad: true,
            iframeCssClass: 'dialog-iframe',
            uri:'#{popUpEditModeURL}'
        }).render();

        // call `popUp.show();` to show the dialog.
    });
</h:outputScript>

Then call popUp.show() whenever you want to show the portlet in edit mode.

Alternatively, you could use a Liferay Faces Alloy's dialog (or any other component suite's dialog) with an iframe inside it to show edit mode in a dialog:

<alloy:dialog height="95%" width="95%" clientKey="dialog">
    <iframe height="100%" width="100%" src="${popUpEditModeURL}" />
</alloy:dialog>

However, this method may not produce exactly the same effect as using Liferay.Util.Window.getWindow().

Full disclosure: I am one of the developers of Liferay Faces Alloy.



来源:https://stackoverflow.com/questions/35162383/how-can-i-open-a-pop-up-of-my-jsf-portlets-edit-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!