Feature Request for Growl Component

UI Components for JSF
Post Reply
User avatar
Daedalus
Posts: 164
Joined: 28 Jan 2010, 12:03

01 Sep 2010, 13:24

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.
PrimeFaces 3.0, Glassfish 3.1.2, Mojarra 2.1.6,

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

26 Jul 2011, 14:51

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

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

26 Jul 2011, 16:45

To add the styleClass behavior just add the following to growl.xml:

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>
Then add the following to GrowlRenderer.java:

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;
        }
Then modify the encodeEnd method in GrowlRenderer.java by adding:

Code: Select all

String styleClass = getStyleClass(facesContext, growl, message);

if(!isValueBlank(styleClass)) {
    writer.write(",class_name:'" + styleClass + "'");
}
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

<p:growl id="growl" errorStyleClass="ui-state-error" infoStyleClass="ui-state-highlight"/>

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

26 Jul 2011, 17:51

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

Code: Select all

<p:growl useLevels="true" id="growl" />
and only if you want to override it, use the errorStyleClass etc?

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

26 Jul 2011, 18:01

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).

damm
Posts: 27
Joined: 27 Apr 2011, 13:55
Location: Cordoba, Argentina

09 Nov 2011, 14:31

Hello bumble.bee, how can I modify growl.xml and GrowlRenderer?

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

09 Nov 2011, 14:32

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

anuja
Posts: 15
Joined: 30 Jan 2012, 09:12

12 Mar 2012, 14:31

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.
PF 3.1.1 / JSF 2.0 / jdk - 1.6 / jboss-6.1.0.Final.
Anuja S.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 33 guests