Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide <p:messages> after it displayed the messages?

I am working on JSF application in primefaces in that i am showing an information to the user via <p:messages> .

So when the user click submit the page will processed and the p:messages dialog will triggered to show the information to the user ,

I referred Primefaces p:messages showcase Page

It is working fine..But after it displayed the messages , it is not closing automatically either we need to close that dialog manually or it remains in open stage.

I need it should it close automatically after it displayed the message to user... How can i do that ...Can anybody give suggestion that how can i do ?

like image 992
kark Avatar asked Mar 23 '23 02:03

kark


1 Answers

<p:messages id="msgs"> is ultimately rendered as <div id="msgs"> and its contents is then updated with the factual messages to the user.

If you want to clear the message screen after some delay you should use the JavaScript setTimeout function after ajax call has been completed:

<p:commandButton ... 
        oncomplete="setTimeout(function() { $('#msgs").html(''); }, 3000);" />

The second parameter of setTimeout function is the delay in milliseconds.

The other alternative is to use <p:growl> instead.

like image 169
skuntsel Avatar answered Apr 05 '23 14:04

skuntsel