You can do it, but it's a bit tricky, due to the asynchronous nature of the 
request.

What I did is that I pass a "callback" (I reused the ValueUpdater 
interface, even though it's not about updating the value, but the method 
signature was exactly what I needed) to the cell; see below.
You also need a cache for the retrieved data, as the cell can be 
re-rendered at any time.

The idea is:

   1. ask the cache (you can use the Cell.Context.getKey() as the cache 
   key, or any ProvidesKey for the value being rendered, or the value itself)
   2. If the value was present in the cache, render it
   3. Otherwise, fire the request and render something in the mean time 
   (e.g. "loading…")
      - when the result comes back, put it into the cache and ask to be 
      re-rendered; this is where I use my ValueUpdater: I simply call the 
      updater's update(), and the view that uses the Cell then decides how to 
do 
      it (in my case, I have a ListDataProvider, so it's as easy as 
      list.set(list.indexOf(value), value); –yes, replacing the value with 
      itself, it's enough to trigger a repaint–)
      - When the Cell will be re-rendered, the value will be in the cache, 
      so the step #2 above will be triggered, instead of step #3, and the 
      retrieved value will be then rendered.
   
I guess you could also generate a placeholder with a unique ID (using 
Document.get().createUniqueId()) the first time, and then use 
Document.get().getElementById() and DOM manipulation (could be as simple as 
a setInnerHTML) to update the value when the response comes back from the 
server; instead of triggering a repaint.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/dsQxmUi4-Q8J.
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