1 Reply Latest reply on May 23, 2007 6:20 AM by ilya_shaikovsky

    How to close a modalPanel?

    vh

      In my modalPanel, I have a ok button. If the operation succeed, the ok button will close the modalPanel, if operation fail, I want to show error msg on the modalPanel and leave it open.
      How do I control if to close the panel?

        • 1. Re: How to close a modalPanel?
          ilya_shaikovsky

          for me - the next code works as you defined.

          <ui:define name="body">
           <f:verbatim>
           <a
           href="javascript:Richfaces.showModalPanel('_panel',{left:'auto', top:'auto'})">Show
           Modal Panel</a>
           </f:verbatim>
           <rich:modalPanel id="_panel">
           <f:facet name="header">
           <h:outputText value="test"></h:outputText>
           </f:facet>
           <h:form id="mpform">
           <a4j:outputPanel ajaxRendered="true">
           <h:messages id="error"></h:messages>
           </a4j:outputPanel>
           <h:inputText value="#{bean.property}" required="true"></h:inputText>
           <a4j:commandLink value="click" oncomplete="windowclose();" reRender="test"/>
           </h:form>
           </rich:modalPanel>
           <script type="text/javascript">
          //<![CDATA[
          function windowclose(){
           if (document.getElementById('mpform:error')==null){
           Richfaces.hideModalPanel('_panel');
           };
          };
           //]]>
          </script>
           </ui:define>
          

          My function just check if the messages appeared and depending on this condition closes the window or does nothing.