0

Refreshing Image in ZK

asked 2006-11-23 19:11:45 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4027727

By: toar

Hi,

I have a question regarding refreshing an image/imagemap with ZK.

What I did is:
1. I have a template image,
src="http://localhost:8080/webappname/img/templates/img0.jpg"
2. I load it up on ZK and display it on my window 3. Based on the user's action, I modify the image and save the changes to the same image location (I change img0.jpg) 4. Then I tried calling invalidate() method on the image instance but the display image doesn't seem to change at all

How would I resolve this?
Is the image cached by the browser?
My ideal solution is to refresh the image as the user clicks on the different area of the image (I'm using imagemap now)


Any help would be really appreciated. And many thanks to the ZK team, I've just started using it lately and I think that it provides really nice interfaces and performs quite well, and it saves me a lot of time when building my web applications.


Regards,
Toar

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2006-11-23 20:49:28 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4027806

By: toar

Another behavior that I find:
1. On an event, when I call

// the code which modify the source image and save it to itself
..

// im is the instance of the image
im.invalidate();

The image doesn't refresh

2. If I call:

// the code which modify the source image and save it to "another_image.jpg"
..

// setting the source to a different image
im.setSrc("another_image.jpg");
im.invalidate();

The image changes to the other image


3. Therefore I tried:

// the code which modify the source image and save it to itself
..

// im is the instance of the image
im.setSrc(im.getSrc());
im.invalidate();

The image is not changed, it is still the old image before it was modified



If I only need to change the image once, then I guess I can do it with #2 (using another image to save it) But I need to change the image a lot, on user click..
Therefore I need to be able to modify one image and refresh it on ZK

Any comments? I'm using FireFox as browser


Thanks

link publish delete flag offensive edit

answered 2006-11-24 03:04:31 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4028046

By: henrichen

The image is cached by the browser. The browser uses the address in "src" as the key to do the caching. You have to give it different addresses to break the cache.

im.setSrc("image.jpg?"+new Date().getTime()); //use the time stamp to break it You don't have to call im.invalidate() since im.setSrc() would do it if src is not the same.

/henri

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2006-11-23 19:11:45 +0800

Seen: 374 times

Last updated: Nov 24 '06

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More