Open Dialog on primefaces as soon as the open screen

4

I have a login screen where I have a Dialog with the Login and Password fields. I wish he would open it as soon as the screen was opened. I read that from version 4.1 of primefaces I have to call Dialog this way: PF('widgetVar').show() but where can I call this Dialog?

    
asked by anonymous 10.06.2015 / 15:12

2 answers

2

You can simply add the visible="true" attribute that automatically <p:dialog> will open when the page is accessed.

Another way beyond what Rafael replied is to do this via jQuery (PrimeFaces already includes in the project):

<script>
    $(document).ready(function(){
        PF('widgetVar').show();
    });
</script>
    
11.06.2015 / 00:08
6

With remoteCommand you can do this. Here's an example.

<p:dialog widgetVar="dlg" width="300" height="300" modal="false">
    teste dialog
</p:dialog>
<p:remoteCommand autoRun="true" oncomplete="PF('dlg').show();"/>
    
10.06.2015 / 22:05