aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Improving the performance of Auto Suggestion Box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Improving the performance of Auto Suggestion Box" Watch "Improving the performance of Auto Suggestion Box" New topic
Author

Improving the performance of Auto Suggestion Box

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
This is how it works.
- Person starts typing into textbox.
- On onkeyPress event, I fire the query.
- I get the result and render it onto JSP.

Case 1: I have just typed 'a'. 'a','e','i' are such words that are found frequently in any string. So, it is obvious that I get more number of rows into result, but even before result gets rendered I type another character and it gets hanged, which is apparent.

My solution : Don't fire query on onKeyPress, but after hitting the Enter key.

How does google search work efficiently on onKeyPress? because of Caching? In my case, I can't do caching as I need to show realtime data.

I think this is very common issue that almost everyone should have faced. Any better approach?

PS :- Did you notice the onChange event of textbox.It is not same as it is for other elements. It's more like onBlur.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Do not send up on first letter, wait to you have 2+
Limit the number of results that comeback
Cache and filter on the client when the server is able to find all of the matches.

onchange fires when the user removes focus from the textbox and the value is different
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Eric Pascarello wrote:Limit the number of results that comeback

This is a good option as I am gonna display only 10 results to user.

Eric Pascarello wrote:Cache and filter on the client when the server is able to find all of the matches.

How can I do caching on client side?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It is up to you how you code it.

I have an object that links to what the user types. I also have a flag that the server returns saying if there are still more options. If there are not any more options for the server to find, I just use what came from the last call to the server and filter that out.

Eric


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Improving the performance of Auto Suggestion Box