Hello,

I've got a strange (at least for me) problem:


Start.java:

new RetrieveDeck(deck);  // this starts a new query to the server
where it gets a json object
System.out.println(deck + " size:" + deck.size()); // get debug
information


RetrieveDeck.java:

public RetrieveDeck(FlashCardList deck) {
        this.deck = deck;

        String url = URL.encode(GWT.getModuleBaseURL() + "sampleDeck");
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

        builder.sendRequest(null, new RequestCallback() {
                @Override
                public void onResponseReceived(Request request,
                        Response response) {
                                        if (200 == response.getStatusCode()) {
                                                JsArray<FlashCardData> tmp = 
FlashCardData
                                                                
.asArrayOfFlashCards(response.getText());

                                                getDeck().populate(tmp); // 
here i pass the data to be added in
a list
                        });

        protected FlashCardList getDeck() {
                return deck;
        }
}


List.java:

public void populate(JsArray<FlashCardData> decks) {
        for (int i = 0; i < decks.length(); i++) {
                add( /* get a lot of infomation and add it to the list */);
        }
        System.out.println(this + " size:" + size());  // get debug
information
}

This all should work fine (I think) but if I run the program I get the
following output:

.client.cards.flashcardl...@19fdee7 size:0 // this is from Start.java
.client.cards.flashcardl...@19fdee7 size:2 // this is form List.java

As you can see the empty list at the beginning is first printed ...
How can I make the program stop until the list is populated?

Thank you very much.
Mark

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to