好吧,我有关闭 p:dialog 的 ap:confirmDialog,但是当我尝试关闭 p:dialog 时,这是行不通的。
这是我的 p:confirmDialog 代码:
<p:confirmDialog id="confirmCancelar" message="Deseja cancelar ?" showEffect="fade" hideEffect="fade"
header="Cancelar" severity="alert" widgetVar="confirmCancelar" appendToBody="true">
<p:commandButton value="Sim" update="messages"
oncomplete="confirmCancelar.hide()"
actionListener="#{dentistaMB.cancelar}" type="button" />
<p:commandButton value="Não" update="messages"
onclick="confirmCancelar.hide()" type="button" />
</p:confirmDialog>
我的 actionListener 是:
public void cancelar(ActionEvent event){
dentista.setPessoaFisica(new PessoaFisica());
dentista.getPessoaFisica().setSexo(new Sexo());
dentista.getPessoaFisica().setEstadoCivil(new EstadoCivil());
dentista.getPessoaFisica().setSituacao(new SituacaoPessoa());
dentista.getPessoaFisica().setUf(new Uf());
RequestContext.getCurrentInstance().execute("dialogCadastrar.hide()");
addInfoMessage("Cancelado com sucesso");
}
当我单击“Não”按钮时,p:ConfirmDialog 隐藏正常,但是当我单击“Sim”按钮时未调用 actionListener,我尝试调试 actionListener 取消器,但从未调用它。
编辑 1
伙计们,我更改了我的代码 p:confirmDialog (代码如下),但现在 p:dialog 正常关闭,但 p:ConfirmDialog 继续在屏幕上。
<p:confirmDialog id="confirmCancelar"
message="Deseja cancelar ?"
showEffect="fade" hideEffect="fade" header="Cancelar"
severity="alert" widgetVar="confirmCancelar"
appendToBody="true">
<p:commandButton value="Sim" oncomplete="confirmCancelar.hide()"
action="#{dentistaMB.cancelar}"
update=":formAlterar" />
<p:commandButton value="Não" onclick="confirmCancelar.hide()"
type="button" />
</p:confirmDialog>