Reputation: 53
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!
Upvotes: 5
Views: 5540
Reputation: 1752
Change the command button to a normal button
<p:commandButton id="confirm" type="submit" value="Your Command Text"/>
Then on the click event call the dialog
<p:commandButton id="confirm" type="button" value="Your Command Text" onclick="dialog.show()"/>
dialog
is the widget var
of your dialog.
Then you can perform your delete operation from a command button inside the confirm dialog.
Looks like you already did this change. You are still getting the same issue?
Upvotes: 3
Reputation: 2790
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>
Upvotes: 4