Implementing a Domino-Suggest

August 4, 2006 at 9:51 am (Ajax, Domino, HTML, JavaScript)

This is a continuation of the series on implementing an interface similar to Google-Suggest on our typical Domino search pages (The first part in the series dealt with Ajax views).

The basic idea behind Google-Suggest is pretty ingenious; as the user types into the textbox, Google would perform a lookup into its index of search-terms and suggest results. The first suggestion would be automatically populated into the textbox, while the rest of the suggestions appear automatically as a SELECT element under the textbox.

I have borrowed the implemntation of the auto-suggest feature from this awesome article, which explains the underlying concepts better than I ever could. The basic premise behind the implementation is to have two classes: an autosuggest textbox class to handle all user-interaction, and a suggestion-provider class to provide the autosuggest textbox with suggestions.

The autosuggest textbox class would take control over the textbox where the user would type in the search-string. It would impose custom handlers over events such as keyup, keydown, keypress etc. Typically, these custom handlers would track the search-string entered (so far), and pass it onto a requestSuggestions() member-method of the suggestion-provider class. In our case, the suggestion-provider class would basically be the wrapper class around the NotesView class that we discussed earlier.

The auto-suggest dropdown is nothing but an absolutely positioned DIV that is created and populated ‘dynamically’. Part 2 of the article explains this concept as well. With all these concepts in tow, implementing a nifty auto-suggest feature in a Domino database should be a cinch.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.