how to let published message show in other new p:growl?

UI Components for JSF
Post Reply
bacon88
Posts: 67
Joined: 29 Aug 2012, 08:36
Location: SiChuang,China

11 Nov 2014, 06:24

I used primefaces 5.1 and Atmosphere 2.2.2

In the Notify case of PUSH showcase,the Notify message will show in p:growl when NotifyView's send() method is invoked,And the p:growl is updated.always only one the p:growl.

I want let the p:growl is showing in new one,not update in the only one when every time the send() is invoked.
could somebody help me?tell me how to do it ?
jdk1.8.0_202 & Java EE 8
primefaces 8.0
Mojarra 2.3.9
GlassFish Server 5.1.0

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

17 Dec 2014, 17:16

Look at the facesmessage code in primefaces push section of PrimeFaces 5.1 user guide, use that code, and modify it a little.

growl one

Code: Select all

<p:growl widgetVar="growl1" showDetail="true" />
growl two

Code: Select all

<p:growl widgetVar="growl2" showDetail="true" />
p:socket

Code: Select all

<p:socket onMessage="handleMessage" channel="/notify" />
javascript: global variable (whichGrowlToUse) and handleMessage()

Code: Select all

<script type="text/javascript">
var whichGrowlToUse = "growl1";
function handleMessage(facesmessage) {
    facesmessage.severity = 'info';
    if (whichGrowlToUse == "growl1") {
        PF('growl1').show([facesmessage]);
        whichGrowlToUse = "growl2";
    }
    else {
        PF('growl2').show([facesmessage]);
        whichGrowlToUse = "growl1";
    }
}
</script>
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 54 guests