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

    How to close a modalPanel?

    vivian hu Novice

      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 Master

          for me - the next code works as you defined.

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

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