4 Replies Latest reply on May 24, 2007 7:03 AM by ilya_shaikovsky

    Modal Window Close

    samyem

      I am trying to implement a modal window to save some data. It has a save button which, when clicked, saves the content in the modal window and then closes the modal window. However, if there are validation problems, it should not close the window.
      The problem is that to close the window, RichFaces uses javascript and the saving part is done by an actionlistener. How would I communicate the result of the actionlistener to the javascript so that the modal window does not close if there are validation problems in the form?

        • 1. Re: Modal Window Close
          samyem

          I found the answer myself after a few experiments:

          <a4j:commandButton reRender="exceptionRegion" data="#{exceptionBean.status}" oncomplete="javascript:(data?parent.closeExceptionEditor():false)" actionListener="#{exceptionBean.onSave}" value="Save"/>

          The exceptionBean.status resolves to a boolean value on my backing bean and it is set to false if we do not want the modal window to close down.

          • 2. Re: Modal Window Close
            kirancsagi

            Can you please explain your solution in details.

            Thanks in advance

            Kiran C Sagi.

            • 3. Re: Modal Window Close
              samyem

              I basically just wanted a way to control the closing event of a modal window from the server side. There are a few ways to do this but I was not sure what would be appropriate. My solution relied on using the "data" attribute of a4j:commandButton to convey the message to close or not to close to the javascript side. Hence you see my javascript snippet for the "oncomplete" event of the button. Not all that intuitive but it worked for me.

              • 4. Re: Modal Window Close
                ilya_shaikovsky