Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have a
p:dialog
that shows after a
p:dataTable
row is clicked. I have a
p:commandButton
in the
p:dialog
and it has an
action
like this:
<p:commandButton value="Cambiar" action="#{adminUsuarios.cambiarPerfil()}" update="tblUsuarios" />
The method cambiarPerfil()
:
public void cambiarPerfil() {
// More stuff here
this.listaUsuarios = null; // Clear the list
That works fine but I want to close the p:dialog
after the p:commandButton action
.
This is the dialog:
<h:form id="myForm">
<!-- More stuff-->
<p:dialog id="myDialog" widgetVar="editarDialog" header="Editar perfil de usuario #{adminUsuarios.usuarioSeleccionado.id_User}" resizable="false" width="400" showEffect="size" hideEffect="size">
<p:commandButton value="Cambiar" action="#{adminUsuarios.cambiarPerfil()}" update="tblUsuarios" />
</p:dialog>
</h:form>
You need to add an oncomplete
client side method in your commandButton
.
<h:form id="myForm">
<p:dialog id="myDialog" widgetVar="editarDialog" ...>
<p:commandButton value="Cambiar" action="#{adminUsuarios.cambiarPerfil()}" update="tblUsuarios" oncomplete="editarDialog.hide();"/>
</p:dialog>
</h:form>
If you're using PF5.0 you might need to change it to oncomplete="PF('editarDialog').hide();"
where editarDialog is your dialog's widgetVar
.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.