Pessoal tenho um dialog que fecha mesmo sem eu chamar o método hide() do mesmo, quando clico em ok ele esta fechando automaticamente porem quero que ele somente feche se setar uma variavel no servidor para ele fechar, abaixo segue o código:
<h:form id="formCadEquipamento">
<p:dialog header="Cadastrar Equipamento" widgetVar="dlgCadEquipamento" resizable="false" id="dialogCadEquipamento" modal="true">
<p:messages id="msgTelaCadEquipamento"/>
<h:panelGrid id="pngCadastrar" columns="4" cellpadding="4" >
<h:outputLabel value="Tag:" style="float: right;"/>
<p:inputText id="idTag" value="#{gerenciamentoCadastroEquipamentosMB.equipamento.tag}" required="true" requiredMessage="O campo é requerido" disabled="false" style="width: 220px;font-weight:bold; "/>
<h:outputLabel value="Potência:" style="float: right;"/>
<p:inputText value="#{gerenciamentoCadastroEquipamentosMB.equipamento.potenciaMax}" disabled="false" style="width: 220px;font-weight:bold; ">
</p:inputText>
<h:outputLabel value="Classificação:" style="float: right;"/>
<p:inputText value="#{gerenciamentoCadastroEquipamentosMB.equipamento.classificacao}" disabled="false" style="width: 220px;font-weight:bold; "/>
<h:outputLabel value="Alcance:" style="float: right;"/>
<p:inputText value="#{gerenciamentoCadastroEquipamentosMB.equipamento.alcance}" disabled="false" style="width: 220px;font-weight:bold; "/>
<h:outputLabel value="Antena:" style="float: right;"/>
<p:selectOneMenu id="antena" value="#{gerenciamentoCadastroEquipamentosMB.idAntena}" style="width: 230px;">
<f:selectItem itemValue="" itemLabel="--Selecionar Antena--"/>
<f:selectItems value="#{gerenciamentoCadastroEquipamentosMB.antenas}" />
</p:selectOneMenu>
<h:outputLabel value="Tipo:" style="float: right;"/>
<p:selectOneMenu id="tipo" value="#{gerenciamentoCadastroEquipamentosMB.idTipo}" style="width: 230px;font-weight: bold;">
<f:selectItem itemValue="" itemLabel="--Selecionar Tipo--"/>
<f:selectItems value="#{gerenciamentoCadastroEquipamentosMB.tipos}" />
</p:selectOneMenu>
<h:outputLabel value="modelo:" style="float: right;"/>
<p:selectOneMenu id="modelo" value="#{gerenciamentoCadastroEquipamentosMB.idModelo}" style="width: 230px;">
<f:selectItem itemValue="" itemLabel="--Selecionar Modelo--"/>
<f:selectItems value="#{gerenciamentoCadastroEquipamentosMB.modelos}" />
</p:selectOneMenu>
<h:outputLabel value="Função:" style="float: right;"/>
<p:selectOneMenu id="funcao" value="#{gerenciamentoCadastroEquipamentosMB.idFuncao}" style="width: 230px;">
<f:selectItem itemValue="" itemLabel="--Selecionar Função--"/>
<f:selectItems value="#{gerenciamentoCadastroEquipamentosMB.funcoes}" />
</p:selectOneMenu>
<h:outputLabel value="Localização:" style="float: right;"/>
<p:selectOneMenu id="localizacao" value="#{gerenciamentoCadastroEquipamentosMB.idLocalizacao}" style="width: 230px;">
<f:selectItem itemValue="" itemLabel="--Selecionar Localização--"/>
<f:selectItems value="#{gerenciamentoCadastroEquipamentosMB.localizacoes}" />
</p:selectOneMenu>
<h:outputLabel value="Responsável:" style="float: right;"/>
<p:selectOneMenu id="responsavel" value="#{gerenciamentoCadastroEquipamentosMB.idResponsavel}" style="width: 230px;">
<f:selectItem itemValue="" itemLabel="--Selecionar Responsável--"/>
<f:selectItems value="#{gerenciamentoCadastroEquipamentosMB.responsaveis}" />
</p:selectOneMenu>
</h:panelGrid>
<p:separator/>
<p:commandButton value="OK" actionListener="#{gerenciamentoCadastroEquipamentosMB.salvar}" update=":formEquipamento:tableEquipamentos :formEquipamento:btnEditar :formEquipamento:btnExcluir :formEquipamento:btnVisualizar :formCadEquipamento:dialogCadEquipamento" />
<p:commandButton value="Cancelar" onclick="dlgCadEquipamento.hide();"/>
</p:dialog>
<script type="text/javascript">
function verificaSucesso() {
var variavel = '#{gerenciamentoCadastroEquipamentosMB.isFechaTela}'; //Aqui pega a variável do Bean
alert('Retornou: ' + variavel);
if (variavel == true) {
alert('Entrou para fechar a tela');
dlgCadEquipamento.hide(); //E aqui verifica se retornou true e pode fechar
}
alert('Deixa a tela aberta');
}
</script>
</h:form>
Se alguem souber como resolver isso agradeço.
.