Text Completion
Hi to all,
i am trying to do text completion...
http://developers.sun.com/jscreator/learning/tutorials/2/textcompletion.html
with the help of the above link i am doing..
Here is my doubt
if i am typing any word means it has to come from my database table...
in above link they are using Dictionary service in Web Service in Server to get the names which is in the Dictionary. for me i have to connect to my database Table, in that what are the names i given which is matching it should has to come..
for that what is the solution..
Suggections are welcome...
[622 byte] By [
helpmeea] at [2007-11-27 4:23:35]

# 1
I did this in my last year's JavaOne Hands-On Lab. Here is some code from that web app:
public void stateAutoComplete_complete(FacesContext context,
String prefix, CompletionResult result) {
try {
// walk through the records and
// add the states that start with
// the prefix to the result
boolean hasNext = stateDataProvider.cursorFirst();
while (hasNext) {
String stateId =
(String)stateDataProvider.getValue(
"STATE.STATEID");
if (stateId != null) {
if (
stateId.toUpperCase().startsWith(
prefix.toUpperCase())) {
result.addItem(stateId);
} else {
// The rest of the states do not have this prefix
if (prefix.compareTo(stateId) < 0) {
break;
}
}
}
hasNext = stateDataProvider.cursorNext();
}
} catch (Exception ex) {
log("Exception getting matching words: " +
ex.getMessage(), ex);
result.addItem("Exception getting the matching words");
// Alternatively, insert the following code.
// Most browsers indicate in the status bar that
// an error has occurred, if browser settings permit.
// throw ex instanceof FacesException ?
//(FacesException) ex: new FacesException(ex);
}
}
You can get the lab from here: http://developers.sun.com/jscreator/community/events/creatorteam.html#handsonla b