Search code examples
primefacesconfirm

Primefaces p:menuitem with p:confirm not supported


I'm trying to call a confirmation dialog on a p:menuitem:

<p:menuitem value="#{text['button.archive']}"  actionListener="#{tasksbacking.archive}" icon="ui-icon-locked">                            
    <p:confirm header="#{text['button.archive.confirm.header']}" 
               message="#{text['button.archive.confirm.message']}"
               icon="ui-icon-alert"/>
</p:menuitem>

but according to the documentation in Primefaces 5:

At the moment p:confirm is supported by p:commandButton and p:commandLink

Is there any way to do this?


Solution

  • I have found better workaround here.

    In two words - include commandlink into menuitem like this:

    ....
    <p:menuitem>
        <p:commandLink>
            <p:confirm>
            </p:confirm>
        </p:commandLink>
    </p:menuitem>
    ....
    

    And you can use global confirmation with this setup. It tested with PF 5.1. Also, it looks like soon it will be implemented in PrimeFaces.