confirmDialog does not work

1

I have an delete button inside my dataTable , but every time I click on it confirmDialog does not appear. I'm doing the following:

<p:column style="width: 100px; text-align: center">
        <p:button icon="ui-icon-pencil" title="Editar" />
        <p:commandButton icon="ui-icon-trash" title="Excluir" oncomplete="confirmacaoExclusao.show()" />
</p:column>

confirmDialog:

<p:confirmDialog header="Exclusão de Produto"
                message="Tem certeza que deseja excluir o Produto?"
                widgetVar="confirmacaoExclusao" severity="alert">
                <p:button value="Não"
                    onclick="confirmacaoExclusao.hide(); return false" />   
                <p:commandButton value="Sim" oncomplete="confirmacaoExclusao.hide();" />

</p:confirmDialog>
    
asked by anonymous 22.06.2015 / 14:38

2 answers

1

Oops, try this:

    <p:confirmDialog id="excluirMensagemModal" width="500"
        header="Confirmação de exclusão" severity="alert"
        widgetVar="excluirManualDialog" closable="false" appendToBody="true">
        <f:facet name="message">
            <h:outputFormat value="Excluir?" />
        </f:facet>

        <p:commandButton value="Sim"
            oncomplete="excluirManualDialog.hide()"
            action="#{seuMBean.delete()}"
            update=":form" />
        <p:commandButton value="Não"
            onclick="excluirManualDialog.hide()" />
    </p:confirmDialog>

Tip: You can use @form rather than , if your confirmDialog is inside the form (if it is inside the form, will not work in IE old versions).

You were not calling the delete action, which is in the action parameter. Without the call to delete nothing will be deleted.

In the call of confirmDialog, the immediate="true" parameter is missing. Make sure it works. Generally I use a commandLink instead of a commandButton , and I use these parameters:

<p:commandLink ajax="true" immediate="true" oncomplete="excluirManualDialog.show()" title="Excluir" update="@form">
                        <f:setPropertyActionListener target="#{meuMBean.editEntity}" value="#{itemDaLista}" />
                        <h:graphicImage value="/resources/img/icons/excluir.png"/>
                    </p:commandLink>

EDIT : When talking to the person who opened the question, we noticed that the error remained because from confirmation of the confirmationDialog call from Primefaces version 5, / p>

PF('widgetVarName').show() ao invés de widgetVarName.show()

Reference response link in the SO in English

    
22.06.2015 / 15:25
0

Try to use this way: <p:column style="width: 100px; text-align: center"> <p:button icon="ui-icon-pencil" title="Editar" /> <p:commandButton icon="ui-icon-trash" title="Excluir> <p:confirm header="Comfirmação" message="Tem certeza que deseja excluir o Produto?" icon="ui-icon-alert" /> </p:commandButton> </p:column>

    
22.06.2015 / 14:54