Skip to content

Adding javascript code to a wicket component with JavascriptAppenderBehavior

Asterios Raptis edited this page Jul 27, 2017 · 3 revisions

In several situations when you develop with wicket you need to integrate some javascript code. Here comes the JavascriptAppenderBehavior in play.

How to use it

If you want to add this behavior to your page you can to this with the following examle:

add(JavascriptAppenderBehavior.builder().id("xy").javascript("alert('foo bar');").build());

this will add the given javascript code with the id 'xy' to your page and show a javascript alert dialog with content 'foo bar'.