Monday, January 9, 2012

loading an image

i try to get an image displayed that is retrieved from an url. my first (false) attempt was not respecting the asynchronous behavior so it only worked in hosted mode:
"
Image image = new Image(someURL);
view.setImage(image);
"
but this failed in "real" mode. so i googled around (besides wrong examples and this ) i found the problem: a have to listen to load event. So i changed my code to this:
"
        image = new Image(url);
        image.addLoadHandler(new LoadHandler() {

            @Override
            public void onLoad(LoadEvent event) {
                view.setImage(image);
                image.setVisible(true);
            }
        });
"
the problem is that the event is never been fired or at least onLoad is never executed. I also tried to addHandler before setting url. The url it self works fine (browser is displaying the image) and log shows positive image response: 
"
response : HTTP/1.1 200 
Content-Type: image/png


graphdata : [B@12505f5
"

so how to correctly load/display an image in gwt?

thx in advance

--
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/-/ngFhnlZ5dcQJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment