I'm doing client-side/javascript validation and would like to trigger the primefaces growl mechanism (which I think is jQuery) just to be consistent with some of the server-side validation that takes place in the app.
Is it possible to trigger a growl popup in javascript?
In this link: viewtopic.php?f=3&t=13399&p=40408&hilit ... owl#p40408 - it sounds like that's not possible but thought I'd ask for clarification.
Thanks,
Joe
trigger growl message from javascript
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
It's possible - just check the renderer!
But it's not user friendly.
Maybe you could create an feature to enhance the growl widget with some client side methods?
But it's not user friendly.
Maybe you could create an feature to enhance the growl widget with some client side methods?
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
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Already available in client side api;
Example with info message;
You need the jar below to use this as client side api of growl change a bit since 3.x.
http://repository.primefaces.org/org/pr ... -SNAPSHOT/
There is also .show(msgs) method where msgs is an array of message objects.
Use removeAll to hide all messages.
See;
http://code.google.com/p/primefaces/sou ... l/growl.js
Code: Select all
<p:growl widgetVar="g" />
Code: Select all
g.renderMessage({summary:'infooo text', detail: 'detaaaaaaail text', severity: 0});
http://repository.primefaces.org/org/pr ... -SNAPSHOT/
There is also .show(msgs) method where msgs is an array of message objects.
Use removeAll to hide all messages.
See;
http://code.google.com/p/primefaces/sou ... l/growl.js
there is no renderMessage method in 3.1.1. Your solution works only in 3.2.heisenberg wrote:Already available in client side api;
Example with info message;Code: Select all
<p:growl widgetVar="g" />
You need the jar below to use this as client side api of growl change a bit since 3.x.Code: Select all
g.renderMessage({summary:'infooo text', detail: 'detaaaaaaail text', severity: 0});
http://repository.primefaces.org/org/pr ... -SNAPSHOT/
There is also .show(msgs) method where msgs is an array of message objects.
Use removeAll to hide all messages.
See;
http://code.google.com/p/primefaces/sou ... l/growl.js
PrimeFaces 3.2| WebLogic 12c | Mojarra (JSF 2.0,1.0.0.0_2-0-2)
NetBeans 7.1.1 | JDK1.7 | Java EE 5
Windows 7, Google Chrome, Firefox, IE9
NetBeans 7.1.1 | JDK1.7 | Java EE 5
Windows 7, Google Chrome, Firefox, IE9
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
As I've said, it has been added as of 3.2.
Btw, I've made that old post during 3.2 development, as of 3.2 final better to use.
show(msgs) removes currently displayed messages and adds msgs.
Btw, I've made that old post during 3.2 development, as of 3.2 final better to use.
Code: Select all
growl.show([{summary:'infooo text', detail: 'detaaaaaaail text', severity: 'info'}, {summary:'warn text', detail: 'detail text', severity: 'warn'}])
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
The link I provided was 3.2-SNAPSHOT.
Whatever, api is there now.
Whatever, api is there now.
Hi, i'm new with primefaces,
i was trying to show the some message in the growl, but why does this doesn't work?
Please help!!!
i was trying to show the some message in the growl, but why does this doesn't work?
Code: Select all
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet"
href="#{request.contextPath}/javax.faces.resource/theme.css.xhtml?ln=primefaces-#{aplicacionManaged.theme}" />
<script>
function muestra(){
jQuery('#growl').show([{
summary:'infooo text',
detail: 'detaaaaaaail text',
severity: 'info'},
{
summary:'warn text',
detail: 'detail text',
severity: 'warn'
}]);
}
</script>
</h:head>
<h:body>
<p:growl id="growl" showDetail="true" life="5000" />
<p:dialog visible="true" id="dialog" header="Login" widgetVar="dlg">
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<f:facet name="footer">
<p:commandButton value="Click Me" type="button" onclick="muestra();" />
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
</h:body>
</html>