confirmDialog does not work

Asked

Viewed 2,639 times

1

I have a delete button inside my dataTable, but every time I click on it confirmDialog does not appear. I am doing as follows:

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

confirm:

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

2 answers

1


Oops, test this way:

    <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 instead of :form, if his confirm is inside the form(if you are inside the form, it will not work in the old versions IE).

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

In the confirmDialog call, the parameter is missing immediate="true". Check if it works. Usually I use a commandLink instead of a commandButton, and 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>

EDITION: When talking to the person who opened the question, we found that the error remained because from Primefaces version 5 or more the call from confirm was changed:

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

Reference response link in the English OS

  • I still wasn’t calling the action to delete anyway, I was just testing the dialog, but it’s hard to make it appear kk. Even with your code not working yet, I click delete and the dialog does not appear

  • Opa, I made an edit, because I see a parameter missing in the confirmDialog call, check the edition and if this parameter was missing.

  • beauty, I’ll test again

  • Yeah, it didn’t work. I’ve followed some tutorials and nothing.

  • I think the problem is in the button that calls the dialog. But I don’t know what can be

  • What else have you tried on the call button besides the one I told you about?

  • I tried to put onComplete, onClick... but nothing works. It’s like this at the moment: <p:commandButton icon="ui-icon-trash" title="Excluir"&#xA; oncomplete="excluirManualDialog.show()" immediate="true"/>

  • I usually use compandLink with icons to make the modal call... take a look, see if you have any ideas. Maybe you’re missing an update, or pass the item you want to delete. <p:commandLink ajax="true" immediate="true" oncomplete="excluirManualDialog.show()" title="delete" update="@form"> <f:setPropertyActionListener target="#{meuMBean.editEntity}" value="#{itemDaLista}" /> <h:graphicImage value="/Resources/img/icons/delete.png"/> </p:commandLink>

  • Didn’t work either.

Show 5 more comments

0

Try to use it like this: <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>

  • Did not work, Dialog does not appear yet

Browser other questions tagged

You are not signed in. Login or sign up in order to post.