Tuesday, July 5, 2011

Improved Autocomplete

We recently made a couple of major improvements to the autocomplete control that comes with Orbeon Forms.

First, we wanted the autocomplete to be simpler for end-users. For the longest time, the autocomplete had the ability to display a show all button to the right of the text field. When users click on that button, all the items (or rather, to be precise, the first n items, where n is configurable) were displayed. This is great for those cases where users don't quite know what they are supposed to type in the text field. We used to have two lists: one showing all the items below the button, and one showing suggestions as you type below the text field. Those two lists have now been unified. The one remaining list provides suggestions as you type, and if you click on the button to the right of an empty field, it shows you all the items.

Second, we wanted to make the autocomplete easier for form authors. We used to have two ways to use the autocomplete. One was to provide the autocomplete with the full list of items, referred to as static mode. From an API perspective, this makes the autocomplete as simple to use as a drop-down, a list, or other selection control. This requires you to have all items in memory on the server, which works if you have, say, a hundred or even a thousand items. What what if your autocomplete allows you to select a product or a book from a collection with millions of items? For that case, the autocomplete provided a lower level, event-based API: the dynamic mode. Several organizations have used the dynamic mode successfully, but it was complicated. So we introduced a third option, referred to as resource mode. In resource mode, you provide the autocomplete with the URL of a service returning a subset of the data in XML format. As users interact with the field, the autocomplete automatically calls your service, providing the text users typed so far as a request parameter, and showing the data returned by your service in the suggestions list.

Bonus: watch the autocomplete automated unit tests as they run, here in Safari (and to see the screen better, you might want to put the video in full screen).


  1. One problem I found with auto-complete is that constraints get applied to the whole instance and if any fail the autocomplete submission fails even if the constraints don't apply to the autocomplete fields.

  2. @davidof Which constraints are you referring to?