Over a million developers have joined DZone.

ZK Gritter: Growl-like notifications for ZK apps

DZone's Guide to

ZK Gritter: Growl-like notifications for ZK apps

· Java Zone ·
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.


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











Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}