Bom Dia, tenho que terminar isso aqui onde trabalho e não sei mais o que fazer, se alguém tiver uma solução será de grande ajuda.
No meu JSF tenho um botão de cadastro, ele é um modalpane do richfaces. Esse botão possui uma chamada para outro modalpanel que verifica se os campos obrigatórios estão preenchidos. Se tiver ele não mostra nada, se faltar algum campo ele da uma mensagem dizendo que tal campo é obrigatório. Mas no meu botão eu também mando ele deixar o modalpanel de cadsatro visível. Dentro dele tem um commandcontrol mandando esconder ele. Só que depois que você da um OK no modalpanel de verificação, preenche os campos obrigatórios e da um CADASTRAR o modal panel não some, sendo que este tem um HIDE.
<%@include file="../../include/tagLibs.jsp"%>
<rich:modalPanel id="mpEndereco" width="500" autosized="true"
moveable="true" resizeable="false">
<f:facet name="header">
<h:outputText value="Endereço" />
</f:facet>
<f:facet name="controls">
</f:facet>
<h:form id="formEndereco">
<h:panelGroup id="panelGroupEndereco">
<h:outputLabel id="outCEP"
value="CEP">
</h:outputLabel>
<h:inputText id="inCEP"
value="#{DenunciaView.denuncia.denunEndereco.endCep}"
disabled="#{DenunciaView.disableCep}" size="8" maxlength="8"
required="true"
requiredMessage="Campo CEP obrigatório">
<rich:jQuery selector="inCEP"
query="mask(99999-999)"
timing="onload" />
<f:converter converterId="converteCep"></f:converter>
<a4j:support reRender="panelGroupEndereco"
event="onblur"
action="#{DenunciaView.buscaPorCep}" ajaxSingle="true"
focus="inLogradouro"></a4j:support>
</h:inputText>
<h:outputLabel id="outLogradouro"
value="Logradouro">
</h:outputLabel>
<h:inputText id="inLogradouro"
value="#{DenunciaView.denuncia.denunEndereco.endLogradouro}"
disabled="#{DenunciaView.disableLogradouro}"
required="true"
requiredMessage="Campo Logradouro obrigatório">
</h:inputText>
<h:outputLabel id="outNumero"
value="Número">
</h:outputLabel>
<h:inputText id="inNumero"
value="#{DenunciaView.denuncia.denunEndereco.endNumero}"
disabled="#{DenunciaView.disableNumero}"
required="true"
requiredMessage="Campo Número obrigatório">
</h:inputText>
<h:outputLabel id="outUF"
value="UF">
</h:outputLabel>
<h:selectOneMenu id="somUF"
value="#{DenunciaView.denuncia.denunEndereco.municipio.estado.estadUf}"
disabled="#{DenunciaView.disableUF}"
valueChangeListener="#{DenunciaView.populaComboBoxMunicipio}"
required="true"
requiredMessage="Campo UF obrigatório">
<f:selectItem itemLabel=" " />
<f:selectItems value="#{DenunciaView.cbEstadoMunicipio.comboxEstado}"/>
<a4j:support reRender="somMunicipio"
event="onchange"
ajaxSingle="true">
</a4j:support>
</h:selectOneMenu>
<h:outputLabel id="outMunicipio"
value="Município">
</h:outputLabel>
<h:selectOneMenu id="somMunicipio"
value="#{DenunciaView.denuncia.denunEndereco.municipio.municCodigo}"
disabled="#{DenunciaView.disableMunicipio}"
required="true"
requiredMessage="Campo Município obrigatório">
<f:selectItem itemValue=" " />
<f:selectItems value="#{DenunciaView.cbEstadoMunicipio.comboxMunicipio}" />
</h:selectOneMenu>
<h:outputLabel id="outBairro"
value="Bairro">
</h:outputLabel>
<h:inputText id="inBairro"
value="#{DenunciaView.denuncia.denunEndereco.endBairro}"
disabled="#{DenunciaView.disableBairro}"
required="true"
requiredMessage="Campo Bairro obrigatório">
</h:inputText>
<h:outputLabel id="outComplemento"
value="Complemento">
</h:outputLabel>
<h:inputText id="inComplemento"
value="#{DenunciaView.denuncia.denunEndereco.endComplemento}"
disabled="#{DenunciaView.disableComplemento}">
</h:inputText>
<h:outputLabel id="outCaixaPostal"
value="Caixa Postal">
</h:outputLabel>
<h:inputText id="inCaixaPostal"
value="#{DenunciaView.denuncia.denunEndereco.endCaixaPostal}"
disabled="#{DenunciaView.disableCaixaPostal}">
</h:inputText>
<a4j:commandButton id="cButtonCadastrar"
value="Cadastrar!"
disabled="#{DenunciaView.disableButtonCadastrarEndereco}"
action="#{DenunciaView.salvarEndereco}"
oncomplete="#{rich:component('mpEndereco')}.show(),
#{rich:component('mpMensagem')}.show()"
reRender="mpMensagem, formEndereco">
<rich:componentControl id="ccCadastrar"
for="mpEndereco"
attachTo="cButtonCadastrar"
operation="hide"
event="onclick">
</rich:componentControl>
</a4j:commandButton>
<a4j:commandButton value="Limpar"
disabled="#{DenunciaView.disableButtonLimparEndereco}"
action="#{DenunciaView.limparCampos}"
reRender="formEndereco"
ajaxSingle="true">
</a4j:commandButton>
</h:panelGroup>
</h:form>
</rich:modalPanel>
Aqui é o modalPanel que verifica se os campos com o required são obrigatórios.
<%@include file="../include/tagLibs.jsp"%>
<rich:modalPanel id="mpMensagem" width="500" autosized="true" moveable="true" resizeable="false">
<f:facet name="header">
<h:outputText value="Mensagem"/>
</f:facet>
<f:facet name="controls">
<h:graphicImage onclick="#{rich:component('mpMensagem')}.hide()"
value="images/close.png" styleClass="hidelinks" />
</f:facet>
<h:form>
<h:messages id="erros" styleClass="msgFatal" fatalClass="msgFatal" infoClass="msgInfo" />
<br/>
<div align="center">
<a4j:commandLink id="btMsgOK" oncomplete="#{rich:component('mpMensagem')}.hide()">
<h:graphicImage id="imgMsgOK" style="cursor:pointer" value="images/btOk.png" />
</a4j:commandLink>
</div>
</h:form>
</rich:modalPanel>
