Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to change images?
How to change images? [message #101849] Mon, 11 August 2008 06:33 Go to next message
Terry  is currently offline Terry Friend
Messages: 19
Registered: July 2009
Junior Member
Hi All:

In my project, I upload a photo for displaying in home page, and it displays
correctly. When I try to replace this photo with a new one, the home page
shows the old photo still. But the new photo has uploaded in server
successfully. If I restart the server, the new photo will be displayed.(Two
photos have same file path.)
I want to know why and how to resolve it?
I use the Graphics.getImage() method to get the Image object.

Best regards,
Terry
Re: How to change images? [message #101871 is a reply to message #101849] Mon, 11 August 2008 07:12 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi,

images are cached by their name and Graphics.getImage() doesn't override
an older image. Is it possbile for you to use a different resource
name if the image's content has changed?

Regards,
Stefan.

Terry Zhang schrieb:
> Hi All:
>
> In my project, I upload a photo for displaying in home page, and it displays
> correctly. When I try to replace this photo with a new one, the home page
> shows the old photo still. But the new photo has uploaded in server
> successfully. If I restart the server, the new photo will be displayed.(Two
> photos have same file path.)
> I want to know why and how to resolve it?
> I use the Graphics.getImage() method to get the Image object.
>
> Best regards,
> Terry
Re: How to change images? [message #101995 is a reply to message #101849] Tue, 12 August 2008 07:11 Go to previous message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080908050400030208060409
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Terry,

(pasted your mail at the bottom).

Another possibility would be to use a ServiceHandler which provides the
images. The ServiceHandler can use a (Session)Singleton to return the
images which have been previously registered at the latter.

You can then use ImageProvider#registerImage() instead of
Graphics#getImage().


Sketch:

class ImageProvider extends SessionSingletonBase {
private Map<String, InputStream> images;

public Image registerImage(String imageId, InputStream is) {
final String imageUrl = ImageServiceHandler.getUrlForImage(imageId);
final Image img = Graphics.getImage(imageUrl, inputStream);

images.put(imageId, img);

}

public void InputStream getImage(String imageId);
}



class ImageServiceHandler implements IServiceHandler {


public void service() throws IOException, ServletException {
String imageId = RWT.getRequest().getParameter("imageId");
ImageProvider.getInstance().getImage(imageId);

// write image to respose stream
}
}


To make Graphics.getImage() compatible with absolute URLs you need to
apply the patch which I attached.

You'll find more information about SessionSingleton and ServiceHandler
in this newsgroup.

Hope this helps,
Stefan.




Terry Zhang schrieb:
> Hello,
>
> Stefan, thanks for your reply.
> But I think it not a best idea for this situation.Because the client
may upload thousands upon thousands photos day by day.If the older image
not clear, the leak memory error will happen in future.
> Is it has another resolve method?
>
> Best regards,
> Terry
>
> Stefan Roeck wrote:
>

--------------080908050400030208060409
Content-Type: text/plain;
name="Patch_ResourceManagerFactory.txt"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="Patch_ResourceManagerFactory.txt"

IyMjIEVjbGlwc2UgV29ya3NwYWNlIFBhdGNoIDEuMA0KI1Agb3JnLmVjbGlw c2UucmFwLnVp
LndvcmtiZW5jaA0KSW5kZXg6IHNyYy9vcmcvZWNsaXBzZS91aS9pbnRlcm5h bC9zZXJ2bGV0
L1Jlc291cmNlTWFuYWdlckZhY3RvcnkuamF2YQ0KPT09PT09PT09PT09PT09 PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0K UkNTIGZpbGU6
IC9jdnNyb290L3RlY2hub2xvZ3kvb3JnLmVjbGlwc2UucmFwL29yZy5lY2xp cHNlLnJhcC51
aS53b3JrYmVuY2gvc3JjL29yZy9lY2xpcHNlL3VpL2ludGVybmFsL3NlcnZs ZXQvUmVzb3Vy
Y2VNYW5hZ2VyRmFjdG9yeS5qYXZhLHYNCnJldHJpZXZpbmcgcmV2aXNpb24g MS43DQpkaWZm
IC11IC1yMS43IFJlc291cmNlTWFuYWdlckZhY3RvcnkuamF2YQ0KLS0tIHNy Yy9vcmcvZWNs
aXBzZS91aS9pbnRlcm5hbC9zZXJ2bGV0L1Jlc291cmNlTWFuYWdlckZhY3Rv cnkuamF2YQk5
IE1hciAyMDA4IDA3OjQxOjQwIC0wMDAwCTEuNw0KKysrIHNyYy9vcmcvZWNs aXBzZS91aS9p
bnRlcm5hbC9zZXJ2bGV0L1Jlc291cmNlTWFuYWdlckZhY3RvcnkuamF2YQkx MiBBdWcgMjAw
OCAwNzowODo1NiAtMDAwMA0KQEAgLTExOSw5ICsxMTksMTEgQEANCiAgICAg fQ0KICAgICAN
CiAgICAgcHVibGljIHZvaWQgcmVnaXN0ZXIoIGZpbmFsIFN0cmluZyBuYW1l LCBmaW5hbCBJ
bnB1dFN0cmVhbSBpcyApIHsNCi0gICAgICByZXNvdXJjZU1hbmFnZXIucmVn aXN0ZXIoIG5h
bWUsIGlzICk7DQotICAgICAgcmVnaXN0ZXJBdEh0dHBTZXJ2aWNlKCBuYW1l ICk7DQotICAg
IH0NCisgICAgCS8vIFJBUCBIQUNLICANCisgICAgCWlmICghbmFtZS5zdGFy dHNXaXRoKCJo
dHRwOiIpKSB7DQorICAgIAkJICAgIHJlc291cmNlTWFuYWdlci5yZWdpc3Rl ciggbmFtZSwg
aXMgKTsNCisgICAgCQkgICAgcmVnaXN0ZXJBdEh0dHBTZXJ2aWNlKCBuYW1l ICk7DQorICAg
IAkJICB9ICAgIH0NCiANCiAgICAgcHVibGljIHZvaWQgcmVnaXN0ZXIoIGZp bmFsIFN0cmlu
ZyBuYW1lLCBmaW5hbCBTdHJpbmcgY2hhcnNldCApIHsNCiAgICAgICByZXNv dXJjZU1hbmFn
ZXIucmVnaXN0ZXIoIG5hbWUsIGNoYXJzZXQgKTsNCg==
--------------080908050400030208060409--
Previous Topic:Question: custom controls and text selection
Next Topic:Custom theme can be applied only via URL
Goto Forum:
  


Current Time: Fri Mar 29 09:52:52 GMT 2024

Powered by FUDForum. Page generated in 0.02416 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top