Image imgObj = new Image ("http:\\testUrl.com\testImage.gif");
it doesnt throw me any exception... What i want to do is, i will try
to get the testImage.gif.. if itz not present i want to display a
default image.. hw can i do it
Thanks in Advance
Amith
You should add a LoadListener to your image and handle the problem in
the onError part. For example:
Image imgObj = new Image ("http:\\testUrl.com\testImage.gif");
imgObj .addLoadListener(new LoadListener(){
public void onError(Widget sender) {
//Window.alert("Expected Error Showing That the onError() Method in
LoadListener works.");
}
public void onLoad(Widget sender) {
//Window.setTitle("Loaded Image: "+imageName);
}
});
You have to make sure that imgObj is added to the DOM though before
trying to load otherwise the onLoad event isnt handled - if you don't
want the image to be visibile when loading, just try
imgObj.setVisible(false)
Hope that helps!
//Adam
Co-author of GWT In Action http://www.manning.com/hanson
More elegantly, and probably what you are already doing, is to put the
Image object in another Panel of some kind. That Panel itself needs
to be added to the DOM structure either by adding it to other Panels,
or using RootPanel.get().add(the panel) or RootPanel.get(name of
slot).add(the panel).
Only once there is a chain from RootPanel to your image will the load
listener get events (since events start in the DOM and then GWT moves
them through widgets/panels that are attached).
If it still doesn't work, feel free to mail me direct using the
address in my profile.
//Adam
Co-author of GWT In Action http://www.manning.com/hanson
RootPanel.get().add(imgObj);
this is what i was looking for.. thats enf for me..
it works....
do chk www.spotDue.com/beta in ur free time and tell me hw can i
improve it...
thnks again
Amith GC