I'm a passionate developer with 10+ years of Java experience. Most of my career has involved JVM- based languages, and nowadays I'm a huge fan of functional programming with languages like Scala and Haskell. My company, Jawsy Solutions, provides software development and consulting services built on my strong grasp of commonly used and bleeding edge JVM-based technical solutions. Joonas is a DZone MVB and is not an employee of DZone and has posted 3 posts at DZone. You can read more from them at their website. View Full User Profile

ZK Gritter: Growl-like notifications for ZK apps

  • submit to reddit

Jawwa ZK Gritter is an open source library that can be used to add Growl-like notifications to ZK apps. The library provides a simple-to-use server-side Java API that can be used to control notifications in the application. Installation instructions are available in the reference manual.

A sample app that demonstrates all the customization options is available at Github:



The library provides a class called Gritter, which contains multiple static methods. Notifications are added using the builder pattern, so you must first obtain a notification builder, build the notification by calling the appropriate methods, and finally complete the builder and show the notification.

Gritter.notification().withTitle("ZK Gritter demo").withText(LOREM_IPSUM).

All notifications require both the title and text parameters, and you must remember to call show or the notification will not be actually shown to the user.


The library supports multiple parameters that can be used to customize the appearance and behaviour of the notifications. The API is fully documented with Javadoc.

Timeout and stickiness

By default all notifications fade out in 6 seconds, but this can be overridden by setting a custom timeout in milliseconds.

Gritter.notification().withTitle("ZK Gritter demo").withText(LOREM_IPSUM).

You can also add sticky notifications that don’t fade out at all unless the user closes them or they are removed programmatically.

Gritter.notification().withTitle("ZK Gritter demo").withText(LOREM_IPSUM).

All visible notifications can be cleared manually. Calling removeAll removes both normal and sticky notifications.


Custom CSS

The sclass parameter can be used to set a custom CSS class.

  .gritter-red .gritter-top {
    background-image: url(gritter-red.png);
  .gritter-red .gritter-item {
    background-image: url(gritter-red.png);
  .gritter-red .gritter-bottom {
    background-image: url(gritter-red.png);
Gritter.notification().withTitle("ZK Gritter demo").withText(LOREM_IPSUM).

Custom image

Notifications can also include an optional 48x48px image.

Java code:

Gritter.notification().withTitle("ZK Gritter demo").withText(LOREM_IPSUM).











Published at DZone with permission of Joonas Javanainen, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)