Java primefaces中其他对话框上的对话框
起初,我为我的英语感到抱歉。 我的应用程序中有一些对话框,每个对话框都能很好地工作,但是当我需要一个对话框来调用另一个对话框时,我很难关闭在第一个对话框上打开的第二个对话框。我通过JavaAPI从primefaces创建它们。什么能解决这个问题 编辑: 好的,我在这里调用我的第一个对话框:Java primefaces中其他对话框上的对话框,java,primefaces,dialog,jsf-2.2,Java,Primefaces,Dialog,Jsf 2.2,起初,我为我的英语感到抱歉。 我的应用程序中有一些对话框,每个对话框都能很好地工作,但是当我需要一个对话框来调用另一个对话框时,我很难关闭在第一个对话框上打开的第二个对话框。我通过JavaAPI从primefaces创建它们。什么能解决这个问题 编辑: 好的,我在这里调用我的第一个对话框: <h:outputLabel value="#{bundle.CreateProfissionalLabel_idRegraComissao}" /> <h:panelGroup>
<h:outputLabel value="#{bundle.CreateProfissionalLabel_idRegraComissao}" />
<h:panelGroup>
<h:inputText readonly="true" value="#{profissionalController.selected.idRegraComissao.descricao}" id="nomeRegraComissao"/>
<p:commandButton value="#{bundle.Pesquisar}" action="#{searchRegraComissaoController.abrirDialogo()}" process="@this" update="@none">
<p:ajax event="dialogReturn" listener="#{profissionalController.regraComissaoSelecionada}" process="@this" update="nomeRegraComissao"/>
</p:commandButton>
</h:panelGroup>
第一个对话框的openDialog方法(searchRegraComissaoController.abirdialogo())是:
public void abrirDialogo() {
Map<String, Object> opcoes = new HashMap<>();
opcoes.put("modal", true);
opcoes.put("resizable", false);
opcoes.put("contentHeight", 470);
RequestContext.getCurrentInstance().openDialog("/webapp/lovs/SearchRegraComissao", opcoes, null);
}
public void abirdialogo(){
Map opcoes=newhashmap();
opcoes.put(“模态”,真);
opcoes.put(“可调整大小”,false);
opcoes.put(“内容高度”,470);
RequestContext.getCurrentInstance().openDialog(“/webapp/lovs/SearchRegraComissao”,opcoes,null);
}
现在我有了一个xhtml文件(/webapp/lovs/SearchRegraComissao.xhtml),它在第一个对话框中呈现,并负责打开第二个对话框。它是如何做到这一点的:
<p:outputLabel value="#{bundle.CreateRegraComissaoLabel_idClinica}" />
<p:panel>
<h:inputText readonly="true" value="#{searchRegraComissaoController.filtro.clinica.nome}" id="nomeClinica"/>
<p:commandButton value="#{bundle.Pesquisar}" actionListener="#{searchClinicaController.abrirDialogo()}" process="@this" update="@none">
<p:ajax event="dialogReturn" listener="#{searchRegraComissaoController.clinicaSelecionada}" process="@this" update="nomeClinica"/>
</p:commandButton>
</p:panel>
在这里,它还有打开第二个对话框的方法:
public void abrirDialogo() {
Map<String, Object> opcoes = new HashMap<>();
opcoes.put("modal", true);
opcoes.put("resizable", false);
opcoes.put("contentHeight", 450);
RequestContext.getCurrentInstance().openDialog("/webapp/lovs/SearchClinica", opcoes, null);
}
<p:column headerText="#{bundle.Acao}">
<p:commandButton value="#{bundle.Escolher}" process="@this" action="#{searchClinicaController.selecionar(clinica)}"/>
</p:column>
public void abirdialogo(){
Map opcoes=newhashmap();
opcoes.put(“模态”,真);
opcoes.put(“可调整大小”,false);
opcoes.put(“内容高度”,450);
RequestContext.getCurrentInstance().openDialog(“/webapp/lovs/SearchClinica”,opcoes,null);
}
到目前为止,一切正常,问题在下一步。现在我有了应该关闭第二个对话框的方法。在用户在第二个对话框中选择dataTable中的一行后调用此方法:
public void abrirDialogo() {
Map<String, Object> opcoes = new HashMap<>();
opcoes.put("modal", true);
opcoes.put("resizable", false);
opcoes.put("contentHeight", 450);
RequestContext.getCurrentInstance().openDialog("/webapp/lovs/SearchClinica", opcoes, null);
}
<p:column headerText="#{bundle.Acao}">
<p:commandButton value="#{bundle.Escolher}" process="@this" action="#{searchClinicaController.selecionar(clinica)}"/>
</p:column>
最后的方法是:
public void selecionar(Clinica clinica) {
clinicas = new ArrayList<>();
//todasClinicas = false;
// isCPF = "CPF";
//nome = "";
RequestContext.getCurrentInstance().closeDialog(clinica);
}
public void seleconar(临床医生){
clinicas=新的ArrayList();
//todasClinicas=假;
//isCPF=“CPF”;
//nome=“”;
RequestContext.getCurrentInstance().closeDialog(clinica);
}
此方法结束时没有错误,但第二个对话框未关闭。有人能帮忙吗
解决方案:我正在阅读primefaces 6指南并使用primefaces 5。在primefaces中,不支持5个嵌套对话框。我刚刚将我的版本更新为6,现在工作正常。今天primefaces 5.2也出现了同样的问题。 我通过添加一个表单和config modal=“true”和appendTo=“@(body)”解决了这个问题 在第二个对话框中。 下面是一个例子: main.xhtml
<h:body>
<h:form id="frmMain">
<p:commandButton value="Open"
process="@this" update="frmMain:dialog1"
oncomplete="PF('wdgDialog1').show()">
</p:commandButton>
<p:dialog id="dialog1" header="Dialog 1"
dynamic="true" modal="true"
widgetVar="wdgDialog1" >
<ui:include src="/dialog/dialog2.xhtml" />
</p:dialog>
</h:form>
</h:body>
dialog2.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<p:dialog id="dialog2" header="Dialog 2"
modal="true" appendTo="@(body)"
widgetVar="wdgDialog" >
<h:form id="frmDialog">
<p:panel>
<p:commandButton value="Test"/>
</p:panel>
</h:form>
</p:dialog>
</ui:composition>
对,添加了代码。您试图关闭的临床医生参数是什么?对于meIt来说,这是一个不正确的对象,当用户在datatable中选择一行时,该对象通过参数传递。我认为closeDialog(clinica)会在上面显示的第三段代码中将clinica返回到ajax事件“dialog return”,这对我不起作用(PF 5.3)。详情如下: