0

is there any way, with GWT, to get progress callbacks for a loading image? we have an app that loads images over a potentially very slow connection and we'd like the user to be able to tell if things are progressing, or just failed completely.

i don't see anything that would leave me to believe this is possible, so just checking myself here.

Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134

1 Answers1

1

GWT compiles down to Javascript. So ultimately GWT can do what Javascript can do.

About your problem: it is doable via XHR, but apparently it does not work in IE: AJAX Page Download progress

The GWT part: you can take any of the Javascript solutions mentioned in the links and wrap it in JSNI.

Update:

XHR and Images dont play nicely together. Here are the workarounds:

  1. Set proper HTTP expire header on the image so that it gets cached. Load it via XHR. Then load it again via image tag. The second request should be handled by the browser cache.
  2. Serve image on your server as Base64-encoded image then wrap it: <img src="data:image/gif;base64,[insert data here]"/>
  3. Various hacks with xhr.overrideMimeType(). You can find them around the net. They behave differently from browser to browser.
Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154