JQuery jGrowl with Wicket

Just one behavior – as simple as that.

public class Growl extends AbstractBehavior {

public Growl(final String title, final String text) {
super();
this.title = title;
this.text = text;
}

@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
StringBuilder script = new StringBuilder();
script.append(“$(document).ready(function() {\n”);
script.append(“$.jGrowl(\”” + protectedString(text) + “\”, { header: ‘” + protectedString(title) + “‘, life: 10000 });”);
script.append(“\n});”);
response.renderJavascript(script.toString(), “Growl”);
}

}

What’s missing is a jQuery-lib and jGrowl-lib Header Contribution if you do not load it by default in your app.

Using it in Wicket:

add(new Growl(“Info”, “My Info Text!”));

If you need it with AJAX, go to this blog.