如何隐藏< p:messages>它显示消息后? [英] How to hide <p:messages> after it displayed the messages?
问题描述
我正在使用Primefaces开发JSF应用程序,因为我正在通过<p:messages>
向用户显示信息.
I am working on JSF application in primefaces in that i am showing an information to the user via <p:messages>
.
因此,当用户单击提交时,将处理页面,并且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 ,
我提到了Primefaces p:messages 展示页面
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 ?
推荐答案
<p:messages id="msgs">
最终呈现为<div id="msgs">
,然后使用向用户发送的实际消息更新其内容.
<p:messages id="msgs">
is ultimately rendered as <div id="msgs">
and its contents is then updated with the factual messages to the user.
如果要在延迟一段时间后清除消息屏幕,则应在ajax调用完成后使用JavaScript setTimeout
函数:
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);" />
setTimeout
函数的第二个参数是延迟(以毫秒为单位).
The second parameter of setTimeout
function is the delay in milliseconds.
另一种替代方法是改用 <p:growl>
.
The other alternative is to use <p:growl>
instead.
这篇关于如何隐藏< p:messages>它显示消息后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!