Hi Team
From javascript, I would like to know what the right way is to show messages. So far I've found this:
PF('globalMessages').appendMessage({"summary":"summary goes here",
"detail":"detail goes here",
"severity":"error"})
<p:messages id="myMsg" widgetVar="globalMessages"></p:messages>
The only problem is that every time and call appendMessage it adds a item in the page.
Is there any way to clear the messages? like PF('globalMessages').clearMessages();
Note: I would like to do this using only javascript, In the client side, our page is calling an external rest API which does not trigger any backend request to our server.
Showing and clearing global error messages using javascript
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
you have to remove those HTML nodes via jquery currently, as there is no util function.
I created a feature request: https://github.com/primefaces/primefaces/issues/10398
I created a feature request: https://github.com/primefaces/primefaces/issues/10398
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
here is a MonkeyPatch you can use right now.
Code: Select all
if (PrimeFaces.widget.Messages) {
PrimeFaces.widget.Messages.prototype.clearMessages = function() {
this.jq.children().remove();
}
}
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
-
- Information
-
Who is online
Users browsing this forum: No registered users and 91 guests