Wicket 1.1-beta and AJAX
Wicket 1.1 has basic, yet highly experimental support for AJAX. Pending our AJAX efforts scheduled for Wicket 1.2, I wanted to show how this AJAX thingy might work using Wicket. Nothing fancy dandy, but something I can use directly in my current project.
NOTA BENE
- this is my first AJAX experiment, so this is definetely not a best practise
- AJAX support is in its infancy in Wicket 1.1, so this may not work in future versions
- Wicket 1.1 is still BETA software. Stuff may break
- I used stuff that is currently only in HEAD (
updateModelchange), so this won’t work with a vanilla wicket-1.1-b1
That said, let’s continue with my AJAX experiment!
My current project will be something like a webbased spreadsheet, so I see a lot of AJAX stuff happening in the future with this project (if that darn manager would only let me): calculations done on the serverside would be done ‘instantaneously’. The results of the calculations would be sent directly to the client, without having to submit anything. Needless to say, I’m pretty enthousiastic on putting AJAX into good use here.
To start slowly I want to update the data on the serverside of a text field on a form without doing a full blown post. Eelco pointed me to the Form input example, where on the integer field an AJAX call is performed (NOTE the demo currenlty only works with internet explorer, this has already been fixed!). This call only calls the validation on the field itself, but this is nearly enough functionality for me to begin with:
- send modified field data to server
- validate value
- when data is valid, update the model
- send status back to client (error or success)
- update class of field to show status
So when I take this code, I should be almost finished. The example uses the dojo toolkit for the AJAX request handling, so this is what I’m using.
The markup for the page I’m creating is very simple: