6

I am using primefaces 5.1, liferay 6.2.0-ga2 and JSF2. I have a page with button. When I press right-click a context menu with one menuitem is displayed. That menuitem must open a new tab, but it doesn't.

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

and the bean

public String openNewTabDetail(final FlexibleDomain application)
{
setApplication(application);
return "application-container";
}

How can I fix it?

1
  • 1
    3 ideas: try with ajax="false". Try with return "/application-container.xhtml?faces-redirect=true". And try giving it a hardcoded url instead of action, if this works target and action apparently dont work together Nov 11, 2015 at 18:50

2 Answers 2

8

There's an issue tagged as "Won'tFix" on Primefaces's GoogleCode for this behavior (p:menuItem not opening a new window using action).

In your case you would need to adapt your action-based navigation for a url based one.

I can't really figure out how to make it work in your project, but my best bet is trying something like this:

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

In the worst case scenario you should try to override Primefaces's p:menuitem default behavior or maybe try to use another component that support this kind of implementation.

Good luck!

0

You can add the attribute ajax="false" along with target="_blank" to the p:menuitem. It should look like this:

<p:menuitem
    value="#{caseList['caseManagement.case.newtab']}" 
    target="_blank"
    ajax="false"
    action="#{applicationManagementBean.openNewTabDetail(unassignedCase)}">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.