You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by fero <fr...@gmail.com> on 2007/09/07 20:03:45 UTC

Disable loading image from browser cache

Hi,
I have a Panel with some images (charts generated with jfreechart) and a
datatable. This Panel is in AjaxTabbedPanel and every time it is accessed
data table is evaluated and charts renewed. But only table is updated and
charts stay the same (they are loaded from cache), they are reloaded only by
pressing CTRL-F5. How to make them update automatically?

Code:
***********************Panel with charts and table***********************

	public CelkoveEmisiePanel(String id, Collection celkoveEmisie) {
		super(id);
		add(emisieTable(celkoveEmisie));
		
		JFreeChartImage poplatkyChart = new JFreeChartImage("chart1", 
pieChart(createDatasetPoplatky(celkoveEmisie),"Poplatky"), 300, 300);
		poplatkyChart.setOutputMarkupId(true);
		add(poplatkyChart);
		
		JFreeChartImage mnozstvoChart = new JFreeChartImage("chart2",
pieChart(createDatasetMnozstvo(celkoveEmisie),"Vypúšťané množstvo"), 300,
300);
		mnozstvoChart.setOutputMarkupId(true);
		add(mnozstvoChart);
	}


*******JFreeChartImage from
http://cwiki.apache.org/WICKET/jfreechart-and-wicket-example.html*****

public class JFreeChartImage extends Image {
	
    private int width;
    private int height;

	public JFreeChartImage(String id, JFreeChart chart, int width, int height){
		super(id, new Model(chart));
		this.width = width;
		this.height = height;
	}

    protected Resource getImageResource() {
        return new DynamicImageResource(){
			
			protected byte[] getImageData() {
		        JFreeChart chart = (JFreeChart)getModelObject();
		        return toImageData(chart.createBufferedImage(width, height));
			}

		    protected void setHeaders(WebResponse response) {
		        if (isCacheable()) {
		            super.setHeaders(response);
		        } else {
		            response.setHeader("Pragma", "no-cache");
		            response.setHeader("Cache-Control", "no-cache");
		            response.setDateHeader("Expires", 0);
		        }
		    }
        };
    }

}
-- 
View this message in context: http://www.nabble.com/Disable-loading-image-from-browser-cache-tf4402977.html#a12560615
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Disable loading image from browser cache

Posted by fero <fr...@gmail.com>.
Thanks Igor. It is working!

Fero



igor.vaynberg wrote:
> 
> extend NonCachingImage instead
> 
> -igor
> 
> 
> On 9/7/07, fero <fr...@gmail.com> wrote:
>>
>>
>> Hi,
>> I have a Panel with some images (charts generated with jfreechart) and a
>> datatable. This Panel is in AjaxTabbedPanel and every time it is accessed
>> data table is evaluated and charts renewed. But only table is updated and
>> charts stay the same (they are loaded from cache), they are reloaded only
>> by
>> pressing CTRL-F5. How to make them update automatically?
>>
>> Code:
>> ***********************Panel with charts and table***********************
>>
>>         public CelkoveEmisiePanel(String id, Collection celkoveEmisie) {
>>                 super(id);
>>                 add(emisieTable(celkoveEmisie));
>>
>>                 JFreeChartImage poplatkyChart = new
>> JFreeChartImage("chart1",
>> pieChart(createDatasetPoplatky(celkoveEmisie),"Poplatky"), 300, 300);
>>                 poplatkyChart.setOutputMarkupId(true);
>>                 add(poplatkyChart);
>>
>>                 JFreeChartImage mnozstvoChart = new
>> JFreeChartImage("chart2",
>> pieChart(createDatasetMnozstvo(celkoveEmisie),"Vypúšťané množstvo"), 300,
>> 300);
>>                 mnozstvoChart.setOutputMarkupId(true);
>>                 add(mnozstvoChart);
>>         }
>>
>>
>> *******JFreeChartImage from
>> http://cwiki.apache.org/WICKET/jfreechart-and-wicket-example.html*****
>>
>> public class JFreeChartImage extends Image {
>>
>>     private int width;
>>     private int height;
>>
>>         public JFreeChartImage(String id, JFreeChart chart, int width,
>> int
>> height){
>>                 super(id, new Model(chart));
>>                 this.width = width;
>>                 this.height = height;
>>         }
>>
>>     protected Resource getImageResource() {
>>         return new DynamicImageResource(){
>>
>>                         protected byte[] getImageData() {
>>                         JFreeChart chart = (JFreeChart)getModelObject();
>>                         return
>> toImageData(chart.createBufferedImage(width,
>> height));
>>                         }
>>
>>                     protected void setHeaders(WebResponse response) {
>>                         if (isCacheable()) {
>>                             super.setHeaders(response);
>>                         } else {
>>                             response.setHeader("Pragma", "no-cache");
>>                             response.setHeader("Cache-Control",
>> "no-cache");
>>                             response.setDateHeader("Expires", 0);
>>                         }
>>                     }
>>         };
>>     }
>>
>> }
>> --
>> View this message in context:
>> http://www.nabble.com/Disable-loading-image-from-browser-cache-tf4402977.html#a12560615
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Disable-loading-image-from-browser-cache-tf4402977.html#a12560815
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Disable loading image from browser cache

Posted by Igor Vaynberg <ig...@gmail.com>.
extend NonCachingImage instead

-igor


On 9/7/07, fero <fr...@gmail.com> wrote:
>
>
> Hi,
> I have a Panel with some images (charts generated with jfreechart) and a
> datatable. This Panel is in AjaxTabbedPanel and every time it is accessed
> data table is evaluated and charts renewed. But only table is updated and
> charts stay the same (they are loaded from cache), they are reloaded only
> by
> pressing CTRL-F5. How to make them update automatically?
>
> Code:
> ***********************Panel with charts and table***********************
>
>         public CelkoveEmisiePanel(String id, Collection celkoveEmisie) {
>                 super(id);
>                 add(emisieTable(celkoveEmisie));
>
>                 JFreeChartImage poplatkyChart = new
> JFreeChartImage("chart1",
> pieChart(createDatasetPoplatky(celkoveEmisie),"Poplatky"), 300, 300);
>                 poplatkyChart.setOutputMarkupId(true);
>                 add(poplatkyChart);
>
>                 JFreeChartImage mnozstvoChart = new
> JFreeChartImage("chart2",
> pieChart(createDatasetMnozstvo(celkoveEmisie),"Vypúšťané množstvo"), 300,
> 300);
>                 mnozstvoChart.setOutputMarkupId(true);
>                 add(mnozstvoChart);
>         }
>
>
> *******JFreeChartImage from
> http://cwiki.apache.org/WICKET/jfreechart-and-wicket-example.html*****
>
> public class JFreeChartImage extends Image {
>
>     private int width;
>     private int height;
>
>         public JFreeChartImage(String id, JFreeChart chart, int width, int
> height){
>                 super(id, new Model(chart));
>                 this.width = width;
>                 this.height = height;
>         }
>
>     protected Resource getImageResource() {
>         return new DynamicImageResource(){
>
>                         protected byte[] getImageData() {
>                         JFreeChart chart = (JFreeChart)getModelObject();
>                         return toImageData(chart.createBufferedImage(width,
> height));
>                         }
>
>                     protected void setHeaders(WebResponse response) {
>                         if (isCacheable()) {
>                             super.setHeaders(response);
>                         } else {
>                             response.setHeader("Pragma", "no-cache");
>                             response.setHeader("Cache-Control",
> "no-cache");
>                             response.setDateHeader("Expires", 0);
>                         }
>                     }
>         };
>     }
>
> }
> --
> View this message in context:
> http://www.nabble.com/Disable-loading-image-from-browser-cache-tf4402977.html#a12560615
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>