Monday, March 23, 2009

Gwt Suggest Box And Rpc

Share it Please
Gwt Suggest Box :

Hi Every One ,

This is my first blog .so please bare me if i need changes.

so what iam going to give you is a code on suggest box , how to make a callback to server for obtaining the suggestions using Suggest.Response and Request

so first let me create the files that are necessary .

On Client Side :

1. a suggestService which extends Remote Service

public interface SuggestService extends RemoteService {
public SuggestOracle.Response getSuggestions(SuggestOracle.Request req);

public static class Util {
public static SuggestServiceAsync getInstance(){
SuggestServiceAsync suggestService= (SuggestServiceAsync)GWT.create(SuggestService.class);
return suggestService;
} interface for AsyncCallback

public interface SuggestServiceAsync {
public void getSuggestions(SuggestOracle.Request req,AsyncCallback callback);

3.a suggestionClass which implements IsSerializable and Suggestion where this will be usefull in obtaining the suggestion supplied from server

public class Suggestions implements IsSerializable, Suggestion
private String suggestions; public String getDisplayString() {
return suggestions;

public String getReplacementString() {
return suggestions;

public Suggestions() { } //Constructor With Suggestion

public Suggestions(String suggestion) {


4. The main important class is SuggestionOracle class which extends SuggestOracle .suggestOracle is used to create suggestions associated with a specific query string

public class SuggestionOracle extends SuggestOracle {

public void requestSuggestions(SuggestOracle.Request req,SuggestOracle.Callback callback) {
SuggestService.Util.getInstance().getSuggestions(req,new ItemRequestCallback(req,callback));

public boolean isDisplayStringHTML() {
return true;

public class ItemRequestCallback implements AsyncCallback{
private SuggestOracle.Request req;
private SuggestOracle.Callback callback;

public void onFailure(Throwable caught) {
callback.onSuggestionsReady(req,new SuggestOracle.Response()); caught.printStackTrace();

public void onSuccess(Object result) {
callback.onSuggestionsReady(req,(SuggestOracle.Response) result);

public ItemRequestCallback(SuggestOracle.Request _req,SuggestOracle.Callback _callback) {
this.req=_req; this.callback=_callback;

we have written all the files that are necessary on the client we will move to server side

1. a class that implements The SuggestService and extends the RemoteServiceServlet

public class SuggestServiceImpl extends RemoteServiceServlet implements
SuggestService {

public Response getSuggestions(Request req) {

SuggestOracle.Response response=new SuggestOracle.Response();

ArrayList oracle=new ArrayList();
oracle.add("American Samoa");
oracle.add("Antigua And Barbuda");
oracle.add("Christmas Island");
oracle.add("Cocos (Keeling) Islands");
oracle.add("Congo, The Democratic Republic Of The");

List mySuggestions = new ArrayList();

for(int i=0;i

return response;

now from your OnModuleLoad() , call as


SuggestionOracle oracle=new SuggestionOracle();
SuggestBox box=new SuggestBox(oracle,new MultipleTextBox());
HorizontalPanel hPanel=new HorizontalPanel();
hPanel.add(new Label("Suggest Box"));


u can check the Image for Demonstration

In My Next Article We Will see how to Create a suggest box which works similarly like the Gmail's "To" Field


  1. This comment has been removed by the author.

  2. do you post information for non-java & non-gwt users. I am very much interested in learning from scratch.

  3. Hello, I гead youг blog lіkе eѵеry
    wееk. Υour ωriting style is witty, keep it

    Feel free tо visіt my site :: Windows 8 Loader By KMSpico

  4. Hi, Neat post. There is an issue with your site in internet explorer,
    may check this? IE still is the market leader and a big section of other folks will pass over your great
    writing due to this problem.

    my web page ... Christian Louboutin Outlet

  5. I'm now not certain where you're getting your
    info, however good topic. I needs to spend a while
    learning much more or working out more. Thank you for fantastic
    information I used to be looking for this information for my
    mission. web design company kerala
    Also visit my webpage ; web design company kerala

  6. This post is invaluable. Where can I find out more?
    Review my web blog :: vuelos a china

  7. You have made some good points there. I checked on the
    internet to find out more about the issue and found most individuals
    will go along with your views on this site.

    my site ... GHD Hair Straightener

  8. What's up, just wanted to say, I enjoyed this blog post.
    It was helpful. Keep on posting!

    Here is my weblog - seo -,

  9. I couldn't resist commenting. Exceptionally well written!

    Feel free to visit my blog :: Versace Scarves

  10. After exploring a number of the blog articles on your site, I seriously appreciate
    yoir technique of writing a blog. I saved it to myy bookmark website list and will be checking back soon. Please check out my web site as well and tell me your opinion.

    Stop by my web page; imprese

  11. Heya i am for the primary time here. I found this board and I in finding
    It really helpful & it helped me out much. I hope to offer something back and
    aid others such as you aided me.

    Feel free to surf to my homepage: Christian Louboutin Wedding Shoes

  12. I visited various web pages however the audio quality for audio songs current at this site is
    truly excellent.

    My web blog ... Christian Louboutin Heels

  13. I was able to find good info from your articles.

    my blog; Christian Louboutin Pumps

  14. Superb, what a weblog it is! This webpage provides useful data to us, keep it

    Here is my web-site gta 5 cheat give weapons

  15. I'm impressed, I have to admit. Rarely do I come across a blog that's equally educative and entertaining,
    and without a doubt, you have hit the nail on the head.
    The problem is something too few people are speaking intelligently about.
    Now i'm very happy I found this during my hunt for something relating
    to this.

    My web-site - fable the lost chapters age hack

  16. Excellent blog right here! Also your website rather a lot up
    very fast! What web host are you the usage of? Can I am getting
    your affiliate hyperlink on your host? I wish my web
    site loaded up as fast as yours lol

    Look into my website clash of clans gem generator

  17. Excellent post! We will be linking to this particularly great article on our website.
    Keep up the great writing.

    Also visit my web site ... high school story cheat for android

  18. I do trust all of the concepts you have offered in your post.
    They are really convincing and can certainly work. Still, the posts are very quick for newbies.
    May you please extend them a little from next time? Thank you for the

    My weblog - gta 5 cheats questions

  19. Thank you for the good writeup. It in fact
    was a amusement account it. Look advanced to far added agreeable
    from you! By the way, how can we communicate?

    my blog :: clash of clans multiplayer

  20. I am genuinely thankful to the owner of this site who has
    shared this impressive post at at this time.

    Review my web page ... Friv2 Games Online

  21. Appreciate the recommendation. Will try it out.

    Also visit my blog ... gta 5 6 milliarden cheat

  22. Greetings from Ohio! I'm bored at work so I decided to
    check out your blog on my iphone during lunch break.
    I love the information you present here and can't wait to take a
    look when I get home. I'm amazed at how fast your blog loaded on my cell phone ..
    I'm not even using WIFI, just 3G .. Anyways, great site!

    Here is my page: Running Shoes

  23. I used to be recommended this blog by way of my cousin. I am no
    longer positive whether this submit is written by way of him as nobody else
    recognise such distinctive about my problem. You're amazing!

    My web blog; New Balance Store

  24. Great post. I used to be checking constantly this blog
    and I am impressed! Very useful information specially the remaining section :
    ) I handle such information a lot. I used to be looking for this certain info for a long time.
    Thanks and best of luck.

    My website - New Balance Minimus

  25. Right here is the right blog for anyone who hopes to understand this topic.
    You know so much its almost hard to argue with you
    (not that I really would want to…HaHa). You certainly put a fresh spin on a subject which has
    been written about for decades. Excellent stuff, just wonderful!

    Also visit my webpage - bp claims

  26. When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get several e-mails with the same comment.
    Is there any way you can remove me from that service?
    Thanks a lot!

    Also visit my site; gta 5 cheat list

  27. My family every time say that I am killing my time here
    at web, however I know I am getting know-how every day by reading such
    fastidious articles or reviews.

  28. If some one desires to be upddated with newest technologies afterward he
    must be visit this website and be up to date daily.