Open Dialog in primefaces as soon as the screen opens

Asked

Viewed 1,312 times

4

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

  • Use the Visible=true attribute of the component itself.

2 answers

6

With the remoteCommandyou can do this. Follow an example.

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

2


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

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

<script>
    $(document).ready(function(){
        PF('widgetVar').show();
    });
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.