0

I have the following

    <p:commandButton  id="menuButton"  value="ADD"  type="button" />
    <p:tieredMenu overlay="true" trigger="menuButton" my="left top" at="left bottom" style="width:150px">
        <p:menuitem id="addProspectLink">
            <p:commandLink action="#{myController.oneAction}" value="Menu One" immediate="true" process="@this">
                <f:param name="id" value="#{myController.idValue}" />
            </p:commandLink>
        </p:menuitem>
        <p:menuitem id="searchProspectLink">
            <p:commandLink action="#{myController.twoAction}"  value="Menu Two" immediate="true" process="@this">
                <f:param name="id" value="#{myController.idValue}" />
            </p:commandLink>
    </p:menuitem>
</p:tieredMenu>

This works fine the way I wanted except that the menu is not hidden once it is clicked.

How can I amend this to hide the link once it is clicked?

Environment : JSF 2.2, PrimeFaces 6.2 and Java 1.7

halfer
  • 19,824
  • 17
  • 99
  • 186
Joe
  • 4,460
  • 19
  • 60
  • 106

1 Answers1

2

The p:tieredMenu has some client side api, simply use the hide() method:

<h:form id="myForm">
    <p:commandButton id="menuButton" value="ADD" type="button" />
    <p:tieredMenu widgetVar="myMenu" overlay="true" trigger="menuButton"
        my="left top" at="left bottom">
        <p:menuitem id="a">
            <p:commandLink value="Reinstate Monica" process="@this"
                immediate="true" action="#{myBean.doSomething()}" onstart="PF('myMenu').hide();"/>
        </p:menuitem>
    </p:tieredMenu>
</h:form>

Not that I have added p:tieredMenu widgetVar="myMenu" and p:commandLink onstart="PF('myMenu').hide();"

Selaron
  • 6,105
  • 4
  • 31
  • 39