how to use GWT suggest box with RPC?
but in specific requirement, i want use suggest box provided by GWT. i cannot get all strings from DB and store in suggest box, as it has 16000 records. so my requirement is as and when user enters 3 charaters i need get the string that 开发者_StackOverflow社区matches 3 chars(like search). please suggest me how to achieve this?
Thanks!
Implement your own SuggestOracle
that, when asked for suggestions, makes an asynchronous server call instead of matching against an in-memory set of strings:
public class MySuggestOracle extends SuggestOracle {
public void requestSuggestions(SuggestOracle.Request suggestRequest,
final SuggestOracle.Callback callback)
{
RequestBuilder rb =
new RequestBuilder(RequestBuilder.GET,
"/suggestions?" + suggestRequest.getQuery());
rb.sendRequest(null, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
// Handle error
}
@Override
public void onResponseReceived(Request rbRequest, Response response) {
SuggestOracle.Response r = new SuggestOracle.Response();
// Fill r based on suggestions in the response parameter.
callback.onSuggestionsReady(suggestRequest, r);
}
});
}
精彩评论