如何打开 JSF portlet 编辑模式的弹出窗口?

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

打开 Liferay portlet 的配置模式时,它会在弹出对话框中打开:

如何让我的 JSF portlet 打开类似的弹出窗口,但用于我的 JSF portlet 的编辑模式?

我正在使用 Liferay 6.2。

在 Liferay 6.2+ 中:

在大多数情况下,您可以打开 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" />

然后在Liferay.Util.Window.getWindow()方法中使用URL:

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

然后在您想要以编辑模式显示 portlet 时调用 popUp.show()

或者,您可以使用 Liferay Faces Alloy's dialog(或任何其他组件套件的对话框),其中包含 iframe,以在对话框中显示编辑模式:

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

但是,此方法可能不会产生与使用 Liferay.Util.Window.getWindow() 完全相同的效果。

完全披露:我是 Liferay Faces 的开发者之一 Alloy。