Search code examples
validationrichfacesmodal-dialog

Keeping a rich:modalPanel open on validation fail?


I'm trying to keep my modal from closing when validation, done with an actionLister, fails.

I've seen numerous discussions on this issue with several purposed solutions but have had no luck with any of them. Anyone have any working solutions?

I'm using RichFaces 3.3.3.Final.


Solution

  • I love StackOverflow because I always find the solution immediately after posting a question.

    The first solution in http://community.jboss.org/wiki/ModalPanelValidation works for me.

    Paraphrased, put an id on your h:messages element and then do this Javascript check to see if you can close the modal.

    function modalClose() {
        if (!document.getElementById('fullresolvedidofmessagepanel')) {
            Richfaces.hideModalPanel('modalpanelid');
        }
    }
    

    The strings here are stand ins.