|
|
Re: How to change images? [message #101995 is a reply to message #101849] |
Tue, 12 August 2008 07:11 |
Stefan 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 PT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1l ICk7DQorICAg
IAkJICB9ICAgIH0NCiANCiAgICAgcHVibGljIHZvaWQgcmVnaXN0ZXIoIGZp bmFsIFN0cmlu
ZyBuYW1lLCBmaW5hbCBTdHJpbmcgY2hhcnNldCApIHsNCiAgICAgICByZXNv dXJjZU1hbmFn
ZXIucmVnaXN0ZXIoIG5hbWUsIGNoYXJzZXQgKTsNCg==
--------------080908050400030208060409--
|
|
|
Powered by
FUDForum. Page generated in 0.03602 seconds