OnLoad P:dialog?

UI Components for JSF
Post Reply
JMilnes
Posts: 110
Joined: 12 Feb 2010, 20:03

21 Oct 2010, 17:05

Can you have p:dialog conditionally display when the page loads?
JSF 2.3.0-FCS Mojarra
Prime faces 3.0.M4
Tomcat 7.0.20
IE 8

User avatar
mouadh
Posts: 85
Joined: 27 Apr 2010, 12:47
Location: Tunisia

21 Oct 2010, 17:30

try :

Code: Select all

<h:body onLoad="dialog.show()">
       <p:dialog widgetvar="dialog"/>
</h:body>
or you can implement your own javaScript to test some conditions then show or hide your dialog
for example :

Code: Select all

function showDialog(){
   if(Condition){
      dialog.show();
   }else{
      dialog.hide();
   }
}
then :

Code: Select all

<h:body onLoad="showDialog();">
       <p:dialog widgetvar="dialog"/>
</h:body>
Last edited by mouadh on 21 Oct 2010, 17:36, edited 1 time in total.
Ben Khalifa Mouadh
engineering student at National School of Computer Sciences - Tunisia
JSF 2.0, GlassFish v3, PF 2.0.1,Majorra 2.0.2, netBeans 6.8

callahan
Posts: 768
Joined: 27 May 2010, 22:52

21 Oct 2010, 17:33

I think <p:dialog visible="true"> also works.

JMilnes
Posts: 110
Joined: 12 Feb 2010, 20:03

21 Oct 2010, 18:16

Thanks for your suggestions. I used visiable="true"
JSF 2.3.0-FCS Mojarra
Prime faces 3.0.M4
Tomcat 7.0.20
IE 8

icordoba
Posts: 67
Joined: 20 Nov 2010, 19:20

08 Nov 2015, 21:09

Hello, I am using Primefaces Mobile 5.3 and onload="true" won't make a dialog show when page loads. Is it not working anymore and there is a different approach?

(I put the p:dialog inside pm:content... it is working when executed from a onclick="" in a button as usually, but ignoring onload="true")

thanks.

robertoteles
Posts: 1
Joined: 06 Mar 2016, 02:27

06 Mar 2016, 02:35

it's a little late so i post my answer for further readers:
Just use Jquery. and PF selector for widgets

Code: Select all

	<script>
		$(function() {
		    PF('dlgWidget').show();
		});
	</script>
Where dlgWidget it's the value of widgetVar attribute in dialog

heather_p
Posts: 10
Joined: 29 Aug 2016, 15:55

21 Feb 2018, 21:30

Yes, I agree with robertoteles. I put my dialog show call in the JQuery onload method, i.e.

Code: Select all

<script type="text/javascript">
                        jQuery(document).ready(function ($) {
                            PF('dlgSearchType').show();
                        });
</script>
works great!

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

22 Feb 2018, 10:25

just set "visible=true" ;)
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 46 guests