Question

I'm doing an asynchronous call to a servlet. In the servlet I am taking some pictures from DB and sending them back to client as Strings. In the Client..in onSuccess(String pictureAsString) method I need to do something with the images after they are loaded and BEFORE going any further. I know the number of images and currently I'm doing some testing like this:

public void onSuccess(String result) {
     numberOfReceivedImages = numberOfReceivedImages-1;
               //add image as string to a list of images
               if(numberOfReceivedImages == 0){
                         ////call method that draws the images from the list                   }
     }

The order in wich the images are drawn should be the order from the list in which the images are stored after receiving them from server, but this order is not kept...and I suppose this is because I'm not receiving all the images by the time I'm drawing them. Thank you, any help is appreciated

Was it helpful?

Solution

Are you sure the images are sent in the right order from the server? How do you store them client-side?

I would suggest that you change the signature of your RPC method to somthing like

AsyncCallback<List<String>> callback = new AsyncCallback()
{
    public void onSuccess( List<String> result ) {
        ...
    }

    ...
}

and of course relevant changes on server side. That way, you're guaranteed the same ordering client side as on server side.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top