Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6038167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:10:44+00:00 2026-05-23T06:10:44+00:00

In Silverlight, a frequently used pattern is: Request data Get back an empty container

  • 0

In Silverlight, a frequently used pattern is:

  1. Request data
  2. Get back an empty container for the data
  3. Asynchronously fire off a query to fill the container
  4. When the query returns, fire an event on the container
  5. Update the UI according to the container’s contents

Can this be done in GWT?

The reason I ask is that I’m trying to make a SuggestBox that contains a list of group names and icons. First, I query Facebook to get a list of groups IDs that are close to the current String in the SuggestBox. Then, I fire off queries to get icons for each group id. The problem is that I have to return the suggestions before those queries are done. I’m not sure how to go back and insert the data after I have it. I don’t want to block until the calls are complete, and there’s no real way to know in advance what data to load.

I could return a widget for the suggestion that loads an image, but the suggestion must be a plain String.

What is the right approach here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:10:45+00:00Added an answer on May 23, 2026 at 6:10 am

    Let’s assume you’re using GWT RPC. You’ll have some service interface that lets you fetch the groupIds for a suggestion and the icon for a specific group id.

    public interface FacebookService extends RemoteService {
    
        List<String> getFacebookGroupIds(String suggestion);
    
        Icon getIconForGroup(String groupId);
    }
    

    You should build your own implementation of Suggestion that can display itself with either just a groupId or a groupId and an Icon.

    public class FacebookGroupSuggestion implements Suggestion {
    
        private String groupId;
    
        private Icon icon;
    
        public FacebookGroupSuggestion(String groupId) {
            this.groupId = groupId;
        }
    
        public String getDisplayString() {
            StringBuilder builder = new StringBuilder();
            builder.append("<b>");
            builder.append(this.groupId);
            builder.append("</b>");
            if (this.icon != null) {
                builder.append(this.icon.toSafeHtml());
            }
            return builder.toString();
        }
    }
    

    I’m using Icon as your own implementation of an icon, it’s not a standard class.
    Then, you can make your implementation of SuggestOracle to fetch the groupIds and icons asynchronously. The SuggestOracle uses a callback to inform the suggestBox that some response to a request is available. So fetch your results, and call the callback when you get them. It’ll look something like this.

    public class FacebookSuggestOracle extends SuggestOracle {
    
        private FacebookServiceAsync service = GWT.create(FacebookService.class);
        private Request currentRequest;
        private Callback currentCallback;
    
        @Override
        public void requestSuggestions(Request request, Callback callback) {
            // Save request & callback for future use.
            this.currentRequest = request;
            this.currentCallback = callback;
    
            // Fetch the groupIds
            service.getFacebookGroupIds(request.getQuery(), new AsyncCallback<List<String>>() {
                public void onSuccess(List<String> result) {
                    createSuggestionsForGroupIds(result);
                }
    
            });
    
        }
    
        private void createSuggestionsForGroupIds(List<String> groupIds) {
            List<FacebookGroupSuggestion> suggestions = new ArrayList<FacebookGroupSuggestion>();
            for (String groupId : groupIds) {
                suggestions.add(new FacebookGroupSuggestion(groupId));
            }
            Response response = new Response(suggestions);
            // Tell the suggestBox to display some new suggestions
            currentCallback.onSuggestionsReady(currentRequest, response);
    
            // Fetch the icons
            for (String groupId : groupIds) {
                service.getIconForGroup(groupId, new AsyncCallback<Icon>() {
    
                    public void onSuccess(Icon result) {
                        // match the icon to the groupId in the suggestion list
                        // use the callback again to tell the display to update itself
    
                    }
    
                });
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Silverlight, the VideoSink.OnSample method is used to get raw webcam data. The function
In Silverlight, how does one get row data from a DataGrid that is full
Silverlight works on client side so putting any sensitive data like connection strings, passwords
Could Silverlight be used for the same things as jQuery, or are they intended
Silverlight is case sensitive for query string parameters so the following code would return
Silverlight 4 with Prism (MVVM pattern). I'm building a filter which is a datatype
In Silverlight, say we start an async request: var request = WebRequest.Create(uri); and then
The Silverlight datagrid seems to load rows (firing off the LoadingRow event) while I
Silverlight v2.0 is getting closer and closer to RTM but I have yet to
Silverlight has been available since quite some time, and Silverlight 2 allows .Net programming

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.