Re: Imagedata isn't reloaded
No, don't do that. It's better to use the last-modified timestamp of the image file. Just extend your RPC method to return the mtime when you request the width and the height. Sorry, I should've explained why this "trick" works. The browser caches the image with its full URL including the query string. When you set the query string to a random value the browser can't use the cached version because its URL is different, in your case, 99.5% of the time. It's also possible, and very likely, that the browser will show an older version of the image. On 8 Sep., 10:50, Paul van Hoven <[EMAIL PROTECTED]> wrote: > Great, this simple trick really works. Thanks a lot. > > I implemented it in the following way: > > Image userPicture = new Image( GWT.getHostPageBaseURL() + > umi.userPic.thumbPath + "?" + Random.nextInt(200)); > > On Sep 8, 12:04 am, Folke <[EMAIL PROTECTED]> wrote: > > > Append a unique ID as query string of the image URL, i.e. the time the > > file was last modified as integer. > > > /upload/images/12345.jpg?1220824911 > > > On Sep 7, 11:34 pm, Paul van Hoven <[EMAIL PROTECTED]> > > wrote: > > > > I have a simple Widget where the user can set its user picture. It has > > > a fileupload and shows the user image. So when the user wants to > > > change his user picture, he simply clicks on the fileupload chooses > > > picture and this is then send to the server. On the server side the > > > picture is safed as "userId".jpg where userId is a unique integer > > > associated with each user. So everytime the user updates his foto, his > > > file named "userId".jpg is simply overwritten, keeps its name and > > > after the fileupload succeeded on the client side in the "public void > > > onSubmitComplete(FormSubmitCompleteEvent event)" method I make an RPC > > > call to the server to retrieve the new image data, such that the user > > > can see his newly changed picture. But there is a problem. > > > > The image in the widget is constructed by > > > > setupWidget() { > > > > > > Image userPicture = new Image( GWT.getHostPageBaseURL() + > > > umi.userPic.thumbPath ); > > > userPicture.setPixelSize( umi.userPic.width, umi.userPic.height ); > > > ... > > > > } > > > > So after having gotten the new image data from the server the method > > > setupWidget() is called andthe new picture gets the same path as the > > > old one was, since the "userId".jpg hasn't changed name but content. > > > The problem: The new image is not reloaded, i.e. the same image as the > > > old one is shown. But the size of the picture changes. So now I have > > > the old picture but poorly scaled. I've already tried not to create a > > > new image but to call "setURL()" on the "old" userpicture. But it > > > doesn't work either. > > > > Why is the image not reloaded properly? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Imagedata isn't reloaded
Great, this simple trick really works. Thanks a lot. I implemented it in the following way: Image userPicture = new Image( GWT.getHostPageBaseURL() + umi.userPic.thumbPath + "?" + Random.nextInt(200)); On Sep 8, 12:04 am, Folke <[EMAIL PROTECTED]> wrote: > Append a unique ID as query string of the image URL, i.e. the time the > file was last modified as integer. > > /upload/images/12345.jpg?1220824911 > > On Sep 7, 11:34 pm, Paul van Hoven <[EMAIL PROTECTED]> > wrote: > > > I have a simple Widget where the user can set its user picture. It has > > a fileupload and shows the user image. So when the user wants to > > change his user picture, he simply clicks on the fileupload chooses > > picture and this is then send to the server. On the server side the > > picture is safed as "userId".jpg where userId is a unique integer > > associated with each user. So everytime the user updates his foto, his > > file named "userId".jpg is simply overwritten, keeps its name and > > after the fileupload succeeded on the client side in the "public void > > onSubmitComplete(FormSubmitCompleteEvent event)" method I make an RPC > > call to the server to retrieve the new image data, such that the user > > can see his newly changed picture. But there is a problem. > > > The image in the widget is constructed by > > > setupWidget() { > > > > Image userPicture = new Image( GWT.getHostPageBaseURL() + > > umi.userPic.thumbPath ); > > userPicture.setPixelSize( umi.userPic.width, umi.userPic.height ); > > ... > > > } > > > So after having gotten the new image data from the server the method > > setupWidget() is called andthe new picture gets the same path as the > > old one was, since the "userId".jpg hasn't changed name but content. > > The problem: The new image is not reloaded, i.e. the same image as the > > old one is shown. But the size of the picture changes. So now I have > > the old picture but poorly scaled. I've already tried not to create a > > new image but to call "setURL()" on the "old" userpicture. But it > > doesn't work either. > > > Why is the image not reloaded properly? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Imagedata isn't reloaded
Append a unique ID as query string of the image URL, i.e. the time the file was last modified as integer. /upload/images/12345.jpg?1220824911 On Sep 7, 11:34 pm, Paul van Hoven <[EMAIL PROTECTED]> wrote: > I have a simple Widget where the user can set its user picture. It has > a fileupload and shows the user image. So when the user wants to > change his user picture, he simply clicks on the fileupload chooses > picture and this is then send to the server. On the server side the > picture is safed as "userId".jpg where userId is a unique integer > associated with each user. So everytime the user updates his foto, his > file named "userId".jpg is simply overwritten, keeps its name and > after the fileupload succeeded on the client side in the "public void > onSubmitComplete(FormSubmitCompleteEvent event)" method I make an RPC > call to the server to retrieve the new image data, such that the user > can see his newly changed picture. But there is a problem. > > The image in the widget is constructed by > > setupWidget() { > > Image userPicture = new Image( GWT.getHostPageBaseURL() + > umi.userPic.thumbPath ); > userPicture.setPixelSize( umi.userPic.width, umi.userPic.height ); > ... > > } > > So after having gotten the new image data from the server the method > setupWidget() is called andthe new picture gets the same path as the > old one was, since the "userId".jpg hasn't changed name but content. > The problem: The new image is not reloaded, i.e. the same image as the > old one is shown. But the size of the picture changes. So now I have > the old picture but poorly scaled. I've already tried not to create a > new image but to call "setURL()" on the "old" userpicture. But it > doesn't work either. > > Why is the image not reloaded properly? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---
Imagedata isn't reloaded
I have a simple Widget where the user can set its user picture. It has a fileupload and shows the user image. So when the user wants to change his user picture, he simply clicks on the fileupload chooses picture and this is then send to the server. On the server side the picture is safed as "userId".jpg where userId is a unique integer associated with each user. So everytime the user updates his foto, his file named "userId".jpg is simply overwritten, keeps its name and after the fileupload succeeded on the client side in the "public void onSubmitComplete(FormSubmitCompleteEvent event)" method I make an RPC call to the server to retrieve the new image data, such that the user can see his newly changed picture. But there is a problem. The image in the widget is constructed by setupWidget() { Image userPicture = new Image( GWT.getHostPageBaseURL() + umi.userPic.thumbPath ); userPicture.setPixelSize( umi.userPic.width, umi.userPic.height ); ... } So after having gotten the new image data from the server the method setupWidget() is called andthe new picture gets the same path as the old one was, since the "userId".jpg hasn't changed name but content. The problem: The new image is not reloaded, i.e. the same image as the old one is shown. But the size of the picture changes. So now I have the old picture but poorly scaled. I've already tried not to create a new image but to call "setURL()" on the "old" userpicture. But it doesn't work either. Why is the image not reloaded properly? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~--~~~~--~~--~--~---