I'm going to use jQwicket for this, which is a JQuery/Wicket integration library
It has a load of useful components, but the one I can use for this particular case is the DialogWebMarkupContainer
component.
JQwicket gives me a fairly painless way of using Javascript, using the Java I know and love. That's as it should be :-)