p:menuitem 中的 target="_blank" 不会打开新选项卡

TuG*_*llo 4 jsf menuitem new-window primefaces jsf-2

我使用的是 primefaces 5.1、liferay 6.2.0-ga2 和 JSF2。我有一个带按钮的页面。当我按右键单击上下文菜单时,会显示一个菜单项。该菜单项必须打开一个新选项卡,但事实并非如此。

<p:commandButton id="viewUnassignedCase"
    action="application-container" styleClass="icon fa fa-eye">
    <f:setPropertyActionListener
        target="#{applicationManagementBean.application}"
        value="#{unassignedCase}" />

    <f:setPropertyActionListener
        target="#{applicationManagementBean.activeIndexTab}" value="0" />
</p:commandButton>

<p:contextMenu for="viewUnassignedCase" id="tableMenu" 
    widgetVar="tableMenu">
    <p:menuitem value="#{caseList['caseManagement.case.newtab']}" 
        target="_blank"
        action="#{applicationManagementBean.openNewTabDetail(unassignedCase)}">
    </p:menuitem>
</p:contextMenu>
Run Code Online (Sandbox Code Playgroud)

和豆

public String openNewTabDetail(final FlexibleDomain application)
{
setApplication(application);
return "application-container";
}
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

Bon*_*cio 6

对于此行为,Primefaces 的 GoogleCode上有一个标记为“Won'tFix”的问题(p:menuItem 未使用操作打开新窗口)。

在您的情况下,您需要将基于操作的导航调整为基于 url 的导航。

我真的不知道如何让它在你的项目中工作,但我最好的办法是尝试这样的事情:

<p:contextMenu for="viewUnassignedCase" id="tableMenu" 
                            widgetVar="tableMenu">
                            <p:menuitem value="#{caseList['caseManagement.case.newtab']}" 
                                target="_blank"
                                url="www.yoururl.com/yourdesiredpath">
                            </p:menuitem>
                        </p:contextMenu>
Run Code Online (Sandbox Code Playgroud)

在最坏的情况下,您应该尝试覆盖 Primefaces 的 p:menuitem 默认行为,或者尝试使用其他支持这种实现的组件。

祝你好运!