In some place in the page puta the grow. Generally the grow is in the form for update with actions. This example make this with javaScript.
<p:growl widgetVar="growMessage" showDetail="true"/>
One socket to listener the channel and call the javascript function.
<p:socket id="socketweb" onMessage="handleMessage" channel="/notify" />Now the messages are inserted by the function handleMessage. When the function show() is called the message appear in the client.
<script type="text/javascript">
function handleMessage(facesmessage) {
facesmessage.severity = 'info';
growMessage.show([facesmessage]);
}
</script>
In managed bean:
To get the Context use pushContext MORE.
The send message use FacesMessage and send to client the message.
public void send() {
FacesMessage message = new FacesMessage();
message.setSeverity(FacesMessage.SEVERITY_INFO);
message.setSummary("Message");
message.setDetail("Message Detail");
pushContext.push("notify", message);
}
Nenhum comentário:
Postar um comentário