pedro, we should probably put the anticaching code into componentrequesttarget. also, whatever url is generated for the prototype ajax call should have a random string appended to it, that way the browser wont cache the response either.
thanks, -igor On Tue, Feb 22, 2011 at 9:52 AM, <[email protected]> wrote: > Author: pedro > Date: Tue Feb 22 17:52:21 2011 > New Revision: 1073435 > > URL: http://svn.apache.org/viewvc?rev=1073435&view=rev > Log: > WICKET-3466 - preventing the response for "click me" link from being cached > > Modified: > > wicket/branches/wicket-1.4.x/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java > > Modified: > wicket/branches/wicket-1.4.x/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java > URL: > http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java?rev=1073435&r1=1073434&r2=1073435&view=diff > ============================================================================== > --- > wicket/branches/wicket-1.4.x/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java > (original) > +++ > wicket/branches/wicket-1.4.x/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/prototype/Index.java > Tue Feb 22 17:52:21 2011 > @@ -16,11 +16,13 @@ > */ > package org.apache.wicket.examples.ajax.prototype; > > +import org.apache.wicket.RequestCycle; > import org.apache.wicket.examples.WicketExamplePage; > import org.apache.wicket.markup.html.basic.Label; > import org.apache.wicket.markup.html.link.ILinkListener; > import org.apache.wicket.markup.html.link.Link; > import org.apache.wicket.model.PropertyModel; > +import org.apache.wicket.protocol.http.WebResponse; > import org.apache.wicket.request.target.component.ComponentRequestTarget; > import org.apache.wicket.util.string.AppendingStringBuffer; > > @@ -47,7 +49,7 @@ public class Index extends WicketExample > public Index() > { > // Add the Ajaxian link to the page... > - add(new Link("link") > + add(new Link<Void>("link") > { > /** > * Handles a click on the link. This method is > accessed normally using a standard http > @@ -60,7 +62,18 @@ public class Index extends WicketExample > count++; > > // The response should refresh the label > displaying the counter. > - getRequestCycle().setRequestTarget(new > ComponentRequestTarget(counter)); > + getRequestCycle().setRequestTarget(new > ComponentRequestTarget(counter) > + { > + @Override > + public void respond(RequestCycle > requestCycle) > + { > + super.respond(requestCycle); > + WebResponse response = > (WebResponse)requestCycle.getResponse(); > + response.setHeader("Pragma", > "no-cache"); > + > response.setHeader("Cache-Control", > + "no-cache, no-store, > max-age=0, must-revalidate"); > + } > + }); > } > > /** > @@ -78,7 +91,7 @@ public class Index extends WicketExample > }); > > // Add the label > - add(counter = new Label("counter", new PropertyModel(this, > "count"))); > + add(counter = new Label("counter", new > PropertyModel<Integer>(this, "count"))); > } > > /** > > >
