Wicket auto-complete text fields

By Adrian Smith30 Aug 2011400 words2 mins to read

It's modern practice in web applications to augment text fields with suggestions while one types. There are plenty of Javascript libraries out there to do that, and plenty of integrations with the Java web framework Wicket out there as well, but somehow none quite did exactly what I wanted, so I've rolled my own Wicket code (based on JQuery).

What I wanted, but what other Wicket / Javascript libraries did not do, were:

Surprisingly all of the above are not particularly easy to achieve simultaneously. But they are now done:

And coupled with my newly created extensive multi-lingual location hierarchy database (hierarchy in the sense of 2nd district -> Vienna -> Austria -> Europe -> World, multi-lingual in the sense I have these displayable strings in various languages), allows me to create a MultipleValueLocationTextField subclass, which can be included in a host HTML page in one line of HTML and one line of Java, and which synchronizes its data with a Location[] in the client code (e.g. straight from/to a domain object), and it looks like this:

(Alas this code only works with Wicket 1.4 and I never upgraded it to work with current versions.)

This article was written by Adrian Smith on 30 Aug 2011

Follow me: Facebook | Twitter | LinkedIn | Email

More on: Java | Things I've Released | Wicket