Hello,
It would be very nice, if the growl component gets a style and styleClass Attbriute to change the look of the produced Messages.
If this is too much effort, it would be enough if i can see on the id of the message from which growl component it came.
So I could add styleclasses with a jQuery expression.
Right know all message ID look like this:
gritter-item-[number]. It would be great if the id is for example idOfGrowl1:gritter-item-[number].
Use Case:
we use the primefaces Growl component to give a user Information. We have two different types of Information. (Important Informations, normal Informations). The basic difference is, that a Important Information is sticky and a normal Information disappears automatically after 5 seconds. Also their look should be different.
It was very easy to implement the wanted behavior. I just use 2 different growl components. One with sticky = true and one with sticky = false. But It is not possible change the Style of one message type without affecting the other.
Feature Request for Growl Component
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
I agree. The growl component isn't flexible enough. The handling of growl messages should be configurable based on severity of the message (I want only error/fatal to be sticky). Also, infoStyleClass, warnStyleClass, errorStyleClass, fatalStyleClass attributes would be nice so that we could control the style (the p:messages component at least renders ui-messages-info, ui-messages-warn, etc). In other words it would be nice to have the option to have the background color of p:growl behave like p:messages (stands out and varies by severity).
Here is an existing issue ticket that covers part of this: http://code.google.com/p/primefaces/iss ... il?id=1535
Created a new ticket for style issue: http://code.google.com/p/primefaces/iss ... il?id=2298
Here is an existing issue ticket that covers part of this: http://code.google.com/p/primefaces/iss ... il?id=1535
Created a new ticket for style issue: http://code.google.com/p/primefaces/iss ... il?id=2298
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
To add the styleClass behavior just add the following to growl.xml:
Then add the following to GrowlRenderer.java:
Then modify the encodeEnd method in GrowlRenderer.java by adding:
Note: growl.js already looks for the class_name attribute and adds it in the appropriate place so no changes are needed there.
You can then style growl like:
Code: Select all
<attribute>
<name>infoStyleClass</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<name>errorStyleClass</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
Code: Select all
protected String getStyleClass(FacesContext facesContext, Growl growl, FacesMessage message) {
FacesMessage.Severity severity = message.getSeverity();
String styleClass = "";
if(severity == null) {
styleClass = "";
} else if(severity.equals(FacesMessage.SEVERITY_INFO)) {
styleClass = growl.getInfoStyleClass();
} else if(severity.equals(FacesMessage.SEVERITY_ERROR)) {
styleClass = growl.getErrorStyleClass();
}
return styleClass;
}
Code: Select all
String styleClass = getStyleClass(facesContext, growl, message);
if(!isValueBlank(styleClass)) {
writer.write(",class_name:'" + styleClass + "'");
}
You can then style growl like:
Code: Select all
<p:growl id="growl" errorStyleClass="ui-state-error" infoStyleClass="ui-state-highlight"/>
Nice addition, but I'd like to extend it a little more. Wouldn't it be nice if there was a parameter that would add these classes by default. Something like
and only if you want to override it, use the errorStyleClass etc?
Code: Select all
<p:growl useLevels="true" id="growl" />
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
The default behavior should probably be to use jQuery ThemeRoller error and highlight classes anyways (info and warn share ui-state-highlight while error and fatal share ui-state-error).
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
Get the source code!
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
hi ,
we got the source code for pf v3.1.1 downloaded from the svn repository,
whenever we change the source code, and build it (in netbeans), the code is refreshed thus losing what i had changed, and hence
the jar file which gets generated is not reflecting my changes.
i had done few change to the inputmask.js file in the source code.
any idea, how to go about it ?
Thanks in advance,
Anuja S.
we got the source code for pf v3.1.1 downloaded from the svn repository,
whenever we change the source code, and build it (in netbeans), the code is refreshed thus losing what i had changed, and hence
the jar file which gets generated is not reflecting my changes.
i had done few change to the inputmask.js file in the source code.
any idea, how to go about it ?
Thanks in advance,
Anuja S.
PF 3.1.1 / JSF 2.0 / jdk - 1.6 / jboss-6.1.0.Final.
Anuja S.
Anuja S.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 33 guests