Growl and Ajax update problem

UI Components for JSF
Post Reply
MikeK
Posts: 104
Joined: 13 Oct 2010, 15:07

11 Mar 2011, 20:28

I am using p:growl to display both validation and a "save successful" message. It works like this.

1) User attempts to save record but has a validation error. Growl displays the validation error.

2) User corrects error and saves. The save successful message displays but the validation error message is not removed.

If I use a non ajax command it works properly but that causes other problems. Does anyone have a suggestion on how to fix this?

Code: Select all

 <p:growl id="message" sticky="true" />

<p:commandButton value="Save" action="#{prop.save}" update="message goal" />
SHORT VERSION:
How to I clear out old growl messages with an ajax call?
Prime Faces 6.2
Mojarra 2.2.14
Apache Tomcat 9.0
Internet Explorer 10,11

MikeK
Posts: 104
Joined: 13 Oct 2010, 15:07

15 Mar 2011, 17:05

In case anyone else has the same problem here is a hack that will fix it. The example works for up to 10 growls. It will remove the old messages and display only the new ones.

Code: Select all

<script type="text/javascript" >

function disableField (id) {
document.getElementById(id).disabled = true;
document.getElementById(id).value = "";
}

function growlFix() {
    disableField(gritter-item-1);
    disableField(gritter-item-2);
    disableField(gritter-item-3);
    disableField(gritter-item-4);
    disableField(gritter-item-5);
    disableField(gritter-item-6);
    disableField(gritter-item-7);
    disableField(gritter-item-8);
    disableField(gritter-item-9);
    disableField(gritter-item-10);
 }
</script>

  <p:commandButton value="Save" action="#{prop.save}"   update="message goal " onclick="javascript:growlFix();"/>
I wish the default would work the same as p:messages or a non Ajax update to growl but at least I can keep using those slick looking Growl messages with this setup.
Prime Faces 6.2
Mojarra 2.2.14
Apache Tomcat 9.0
Internet Explorer 10,11

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

02 Apr 2011, 16:21

3.0's growl automatically removes previous messages before showing new ones when updated with ajax;

http://code.google.com/p/primefaces/iss ... il?id=1925

MikeK
Posts: 104
Joined: 13 Oct 2010, 15:07

03 Apr 2011, 01:11

Great news! I know we gripe a lot on this forum so I just wanted to say thanks for the upgrade and keeping us informed.
Prime Faces 6.2
Mojarra 2.2.14
Apache Tomcat 9.0
Internet Explorer 10,11

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

03 Apr 2011, 11:33

Thanks for your feedback that initiated this enhancement.

matias-uy
Posts: 31
Joined: 27 May 2013, 00:12

10 Jul 2013, 08:04

Is it posible to deactivate the behaviour of removing old messages in growl?
Lets say that the lifetime of each message is 3 seconds, what I want to do is something like this:

time (seconds) - event
0 - show message 1
1 - show message 2
2 -
3 - hide message 1
4 - hide message 2

Thanks! Matias

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

10 Jul 2013, 08:36

new questions in new topics pease

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests