Haven't tested this, but it could be a start...

                final RenderedDynamicImageResource rd = new 
RenderedDynamicImageResource(100, 100) {
 
                        @Override
                        protected boolean render(Graphics2D graphics) {
                                return false;
                        }

                };
 
                final NonCachingImage nci = new NonCachingImage("img") {

                        @Override
                        protected Resource getImageResource() {
                                return rd;
                        }

                };




From:   Carl-Eric Menzel <[email protected]>
To:     [email protected]
Date:   11/18/2010 07:43 AM
Subject:        Non-caching RenderedDynamicImageResource



Hi,

we're rendering some charts using JFreeChart and
RenderedDynamicImageResource (that combination is pretty neat, by the
way). However, RenderedDynamicImageResource caches its image data,
even when I call setCacheable(false). When I refresh the page using
AJAX, for example, I get the same image, even though the underlying
model data has changed.

I worked around this by creating a
NonCachingRenderedDynamicImageResource:

public abstract class NonCachingRenderedDynamicImageResource extends
  RenderedDynamicImageResource { 

public
  NonCachingRenderedDynamicImageResource(int width, int height)
{ super(width, height); }

    @Override
    protected byte[] getImageData() {
        return render();
    }
}

I'm simply overwriting getImageData() to skip the caching logic in
there. This seems to work fine.

I'm wondering, however, whether this is really the right way to go
about this. Should RenderedDynamicImageResource maybe check the
cacheable flag before actually caching the image data? If so, I could
provide a patch.

Thanks
Carl-Eric
www.wicketbuch.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]






Notice: This communication, including any attachments, is intended solely 
for the use of the individual or entity to which it is addressed. This 
communication may contain information that is protected from disclosure 
under State and/or Federal law. Please notify the sender immediately if 
you have received this communication in error and delete this email from 
your system. If you are not the intended recipient, you are requested not 
to disclose, copy, distribute or take any action in reliance on the 
contents of this information.

Reply via email to