0

I try to control primefaces display show and hide from java script on bean validation failure, but its not working. As suggested in forums have tried with widgetVar name of the component in javascript and even tried with id of the component but failed.

XHTML

<p:dialog header="Modal Dialog" id="mglasspaneid" showHeader="false" closable="true" resizable="false" draggable="false" widgetVar="mglasspane" style="height: 50px !important;" modal="true">
        <span id="loading" draggable="false" style="height: auto !important;">Loading</span>
</p:dialog>

Javascript

<script>
        function handleComplete(data) {
            if (data.status === 'success') { 

               console.log(document.getElementById('validation-failed').value);
               mglasspane.hide();

            }else{
                console.log(document.getElementById('validation-failed').value);
                mglasspane.show();
            }                
        }
</script>
3
  • any javascript errors? And what PF version? Commented Jun 29, 2015 at 7:01
  • @Kukeltje Primefaces 5.2,Error: ReferenceError : mglasspane is not defined Commented Jun 29, 2015 at 7:48
  • possible duplicate of Get primefaces widgetVar in javascript and update it Commented Jun 29, 2015 at 8:53

1 Answer 1

2

From PrimeFaces 5.0 you must call any component with the PF function (i.e. PF('widgtVar') instead of widgetVar which has already been deprecated in 4.0). Source here.

Replacing mglasspane.hide(); by PF('mglasspane').hide(); should work.


More information about the PF function here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.