Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces confirmDialog does nothing in actionListener

I have a comandButton which calls to a confirmDialog which must eliminate a user, but it never calls method that there is in its actionListener.

This is the code:

<p:dialog id="dialogEditar" widgetVar="dialogEditar" header="#{bundle_usuarios.usuarios_titulo_edicion}" resizable="false">
    <p:panelGrid id="panelEditar"
        <p:row>
            <p:column>
                <p:commandButton id="btModificar" type="submit" actionListener="#{usuariosMB.modificarUsuario()}"
                             value="#{bundle_general.general_modificar}" update="formEditar" rendered="#{usuariosMB.permisoCtMenu}"/>
            </p:column>
            <p:column colspan="7">
                <p:commandButton id="btEliminar" type="button" onclick="confirmation.show()"
                              value="#{bundle_general.general_eliminar}"/>
            </p:column>
        </p:row>
    </p:panelGrid>
    <p:confirmDialog appendToBody="true" id="confirmDialog" message="#{bundle_usuarios.usuarios_confirma}"
                     header="#{bundle_usuarios.usuarios_titulo_confirma_eliminar}" severity="alert" widgetVar="confirmation">
        <p:commandButton id="confirm" type="submit" value="#{bundle_usuarios.usuarios_aceptar_eliminar}"
                         update="dialogEditar, formEditar" oncomplete="confirmation.hide()"
                         actionListener="#{usuariosMB.eliminarUsuario()}" rendered="#{usuariosMB.permisoCtMenu}" /> 
        <p:commandButton id="decline" value="#{bundle_usuarios.general_cancelar}" onclick="confirmation.hide()" type="button" />
    </p:confirmDialog>
</p:dialog>

If i put the same code, without confirmDialog, it runs and deletes the user without problems.

The code that runs with success is the next:

<p:dialog id="dialogEditar" widgetVar="dialogEditar" header="#{bundle_usuarios.usuarios_titulo_edicion}" resizable="false">
    <p:panelGrid id="panelEditar"
        <p:row>
            <p:column>
                <p:commandButton id="btModificar" type="submit" actionListener="#{usuariosMB.modificarUsuario()}"
                             value="#{bundle_general.general_modificar}" update="formEditar" rendered="#{usuariosMB.permisoCtMenu}"/>
            </p:column>
            <p:column colspan="7">
                 <p:commandButton id="btEliminar" type="submit" actionListener="#{usuariosMB.eliminarUsuario()}" value="#{bundle_general.general_eliminar}" update="dialogEditar, formEditar" rendered="#{usuariosMB.permisoCtMenu}"/>
            </p:column>
        </p:row>
    </p:panelGrid>
</p:dialog>

Another thing, when I click on the commandButon with id="confirm", the confirmDialog never dissapear and it stays blocked in the window.

If you need more details, say me which require. Please, any suggestion? Thanks!

like image 494
Darkfalk Avatar asked Nov 30 '12 09:11

Darkfalk


1 Answers

If your dialog placed in a h:form it is a good exercise to carry out from this form and place a h:form inside the dialog. Still you would be able to access via widgetVar

<h:form>
....
</h:form>

<p:dialog>

<h:form>
...
<p:commandButton />
<h:form>

</p:dialog>
like image 160
HRgiger Avatar answered Sep 19 '22 19:09

HRgiger