开发者

Showing Suggestions below text field taking values from database

开发者 https://www.devze.com 2023-01-18 03:24 出处:网络
I am having a form. I want to show user suggestions about the name of the security he can enter. For the same I want to use the values of securities that I have installed in my Oracle Database.

I am having a form. I want to show user suggestions about the name of the security he can enter. For the same I want to use the values of securities that I have installed in my Oracle Database.

I want to do something like this, if user enters a, he should get all security names below the text field which starts from a, when user selects anyone of them, then the text field must show the sele开发者_Go百科cted values.

Thanks in Advance.


You need autocomplete enabled text field. There's a tutorial how to build one. Even better, use jQuery java script library for this and many other features.


I'd suggest a trie. They are great for things like predicive text and auto complete.

Get all the valid security names and put them into the trie, then query the trie with whatever prefix the use has entered and it will give you all the matching names.

Note that Java doesn't come with a Trie implementation itself buy it would be pretty easy to write your own or borrow one, for eg from here; http://forums.sun.com/thread.jspa?threadID=5295936

Edit: You didn't say if this was going to be on the web or desktop (eg Swing)....

0

精彩评论

暂无评论...
验证码 换一张
取 消