Wicket Javascript Internals dissected

SO you need to do something special with a javascript and you want to integrate that with wicket. In my last article I looked at this from the wicket side and wrote about what you can do to push something out from wicket. But what if you want to interact? Then you will have to take a peek at wickets javascript internals. If you are working on an ajax component you get these wicket javascript source files included as default:

  1. wicket-event.js
  2. wicket-ajax.js


This file contains everything Wicket needs for event handling, but also methods for detecting browser like Wicket.Browser.isIELessThan7() which could come in handy if youre doing your own script, no need to write it again..


This file hold everything Wicket needs for doing ajax. So it’s a big file containing a lot of interesting possibilities.

The most interesting method are wicketAjaxGet its the way to contact the server doing ajax. It’s signature are this:

The first parameter are the url for wicketAjaxGet to call server side with, it usually gets generated from serverside, and you can add parameters to it and get them server side. Furthermore it takes 3 functions and a channel. Channel are also usually populated for you so dont think about that. The functions however are called either on sucess, failure or as a precondition. These supply very nice options for you if you need to do something special with the result of the wicketAjaxGet you can put in callbacks. Small example from the mooTip ajax integration:

As you can see, if you count the parameters, I put in a success method for wicket to call once the request has finished, in this case it sets up a tooltip and displays it, by a method thats passed along using the content of the dom element called ‘mooTipContent’.

Theres also lighter methods like for example wicketHide and wicketshow. Methods for manipulating visibility of dom objects. Theres many more functions in there. But these should get you going.

The complete package

A small example that shows a invisible veil when a abstractajaxTimerEventBehavior is called:

And thats it, now you should be ready to do your own stuff :)

One Response to “Wicket Javascript Internals dissected”

  1. [...] Our implementation (override) of the “makeConnection” method uses the Wicket Ajax engine to GET data from a given URL and we pass a callback function that will call “handleResponse” once the response from the server is received. The value typed by the user is passed as as a query-string parameter “q” which will be read on the server-side. Update: for more details on the lightweight Ajax engine and JavaScript utilities that come along with Wicket, refer this article by Nino Martinez: Wicket Javascript Internals dissected [...]

Leave a Reply