Thanks for the suggestion Jeremy.
Here is the solution I eventually settled on, in case anyone is
searching the mail archives on the same keywords I used.
My solution basically checks to see if a shared image resource has
been mounted, and if not, mounts it. Thereafter, each time the page
is reloaded, the mounted shared image resource is used. The URLs of
my images wind up looking like "resources/images/
myUniqueImageName.jpg" (which allows the browser to cache
myUniqueImageName.jpg). My particular works because my images all
have unique names (if the images didn't have unique names I'd have to
put in some scoping in the SharedResource).
Anyhoo, this is the solution...Something similar to this was added
within the constructor of my page.
LsApplication app = LsApplication.get();
SharedResources sharedResources = app.getSharedResources();
IImageService imageService = ...injected by Spring...
String imageName = imageService.getImageName(...); // e.g.
"myUniqueImageName.jpg"
if (sharedResources.get(LsApplication.class, imageName, null,
null, false) == null) {
Resource resource = new DynamicImageResource() {
@Override
protected byte[] getImageData() {
return imageService.saveImageInTmpAndGetBytes(...);
}
};
sharedResources.putClassAlias(LsApplication.class, "images");
sharedResources.add(LsApplication.class, imageName, null,
null, resource);
app.mountSharedResource(imageName, imageName);
}
add(new Image("image", new ResourceReference(LsApplication.class,
imageName)));
- Justin
On Jun 23, 2008, at 7:05 PM, Jeremy Thomerson wrote:
I'm pretty sure you'll find an answer in the archives. For instance,
there's a bunch of suggestions here:
http://www.nabble.com/Image-from-resource-outside-tomcat-container-to17276444.html#a17276444
--
Jeremy Thomerson
http://www.wickettraining.com
On Mon, Jun 23, 2008 at 7:04 PM, Justin Morgan - Logic Sector <
[EMAIL PROTECTED]> wrote:
In my web app there are a bunch of static image files that live
outside the
WAR in various places on the host's file system (also outside the
purview of
the httpd server too). To serve up these images within my Wicket
app, I've
been reading their bytes via a File object and returning those
bytes to an
Image via a DynamicImageResource. As usual, the Image is added to
the page
in the page's constructor.
This works great except for one problem...
Each time the user reloads the page, the HTML <img> gets a new "src"
attribute because a new DynamicImageResource is created each time
the page
is instantiated. Thus, the browser can't cache the image. This is
bad
because I want the image to be cached.
My question is: How can I provide a non-changing URL for the image
resource so the image is cacheable?
Many thanks for any help.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]