2

I want to show a dialog only three seconds and after close it automatically and redirect an other faces page. How can I do it?

Thanks in Advance.

The dialog:

<p:dialog id="dialog" header="Message" widgetVar="dlg1">  
<h:outputText value="your account is being blocked......" />  
</p:dialog>  
4

1 回答 1

3

Dialog has two attributes onShow and onHide(you can reference in Primefaces doc), and you can use timeout to do it, you can try:

<p:dialog widgetVar="dlg1" onShow="myFunction();" onHide="myStopFunction();"> </p:dialog>
<script>
var myVar;

function myFunction()
{
myVar=setTimeout(function(){ dlg1.hide()},3000);
}

function myStopFunction()
{
clearTimeout(myVar);
}
</script>
于 2013-09-10T07:16:09.477 回答