You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by hfriederichs <h....@ohra.nl> on 2011/11/07 16:20:09 UTC
Migrating a ResourceStreamRequestTarget to a
ResourceStreamRequestHandler
I'm experiencing strange behaviour in migrating a ResourceStreamRequestTarget
to a ResourceStreamRequestHandler.
It worked fine in Wicket 1.4.x
I have a button for downloading an installation manual. Which manual should
be downloaded
depends on the user's input. In some cases there isn't a manual, and so I
couldn't use a
WebRecource, because I wanted to show an infomessage in that case. The
solution was a Link with
an onClick. in pseudocode:
Link<String> downloadInstallationmanualButton = new
Link<String>("downloadinstallationmanual", new Model<String>()) {
@Override
public void onClick() {
if (user didn't supply any data) {
info("Please supply this and that");
return;
}
//create an implementation of IResourcestream called
InstallationManualResourceStream
IResourcestream theInstallationManualResourceStream = new
InstallationManualResourceStream();
if (theInstallationManualResourceStream.manualNotfound) {
info("No manual found for your input");
return;
}
ResourceStreamRequestTarget resourceStreamRequestTarget = new
ResourceStreamRequestTarget(
theInstallationManualResourceStream,
theFileName);
RequestCycle.get().setRequestTarget(resourceStreamRequestTarget);
}
As I mentioned, this worked perfect.
As part of the migration to Wicket 1.5.(2), I replaced the last two
statements by:
ResourceStreamRequestHandler resourceStreamRequestHandler = new
ResourceStreamRequestHandler(
theInstallationManualResourceStream,
theFileName);
RequestCycle.get().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler);
When I click on the button after a server restart and opening of a fresh
browser, the onClick isn't
executed. Instead, the browser's (FireFox) save or open popup occurs, with
download-data of the
Session before the server restart, a sort of browser caching?
Only when I have pressed the browser's refresh (F5) twice, the onclick is
executed.
After that, it never executes again, and so the IResource isn't updated.
Shouldn't the onClick always be executed?
What am I doing wrong?
Thanks in advance, Hans Friederichs
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p3998969.html
Sent from the Users forum 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: Migrating a ResourceStreamRequestTarget to a
ResourceStreamRequestHandler
Posted by hfriederichs <h....@ohra.nl>.
In adddition: it works fine in IE8!
I'm using firefox 8.0;
Chrome 11.0.696.71: same problem as Firefox...
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p4017378.html
Sent from the Users forum 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: Migrating a ResourceStreamRequestTarget to a
ResourceStreamRequestHandler
Posted by hfriederichs <h....@ohra.nl>.
I will try these suggestions, but I't is quite frustrating that migrating
such a simple function causes so much problems.
In the meanwhile, I read the improvements in the caching mechanisms of
Wicket 1.5 on
https://cwiki.apache.org/WICKET/caching-in-wicket-15.html
It says:
/Caching is uniformly disabled now by sending the following HTTP response
headers:/
So I tried:
HttpServletResponse response =
(HttpServletResponse)getResponse().getContainerResponse();
response.addHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "no-cache, no-store");
response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:00 GMT");
at various places.
I also put
((WebResponse) getResponse()).disableCaching();
in the body of the onClick,
But Firefox is still caching like a madman!!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p4017233.html
Sent from the Users forum 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: Migrating a ResourceStreamRequestTarget to a ResourceStreamRequestHandler
Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Nov 7, 2011 at 9:35 PM, hfriederichs <h....@ohra.nl> wrote:
> Can anyone explain to me why an onClick() is executed only once after two
> refreshes and then never again?
> What blocks the firing of this event? Maybe that gives me a clue so that I
> can figure it out.
See Firebug's Net tab. It will tell you whether the server is hit or
the cache is used.
You can also set a breakpoint in WicketFilter#doFilter() and whether
it stops there for each request.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p4013453.html
> Sent from the Users forum 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
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Migrating a ResourceStreamRequestTarget to a
ResourceStreamRequestHandler
Posted by hfriederichs <h....@ohra.nl>.
Can anyone explain to me why an onClick() is executed only once after two
refreshes and then never again?
What blocks the firing of this event? Maybe that gives me a clue so that I
can figure it out.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p4013453.html
Sent from the Users forum 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: Migrating a ResourceStreamRequestTarget to a
ResourceStreamRequestHandler
Posted by hfriederichs <h....@ohra.nl>.
I added this to my Page:
@Override
protected void setHeaders(WebResponse response) {
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache, max-age=0,
must-revalidate, no-store");
}
It doesn't help.
The onClick is still only executed once after two refreshes. Isn't that an
issue that should be solved first?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p4003868.html
Sent from the Users forum 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: Migrating a ResourceStreamRequestTarget to a ResourceStreamRequestHandler
Posted by Martin Grigorov <mg...@apache.org>.
On Mon, Nov 7, 2011 at 5:50 PM, hfriederichs <h....@ohra.nl> wrote:
> Hi Martin,
>
> I forgot to mention: I tried that, but to no avail.
> As the onClick isn't executed, the disableCaching isn't either.
> Even when the onClick executes after two refreshes, it doesn't after that
> single occasion.
Please check the response headers after a successful execute of
#onClick() and verify that the no-cache headers are there
>
>
> Hans
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p4001432.html
> Sent from the Users forum 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
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Migrating a ResourceStreamRequestTarget to a
ResourceStreamRequestHandler
Posted by hfriederichs <h....@ohra.nl>.
Hi Martin,
I forgot to mention: I tried that, but to no avail.
As the onClick isn't executed, the disableCaching isn't either.
Even when the onClick executes after two refreshes, it doesn't after that
single occasion.
Hans
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p4001432.html
Sent from the Users forum 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: Migrating a ResourceStreamRequestTarget to a ResourceStreamRequestHandler
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
On Mon, Nov 7, 2011 at 5:20 PM, hfriederichs <h....@ohra.nl> wrote:
> I'm experiencing strange behaviour in migrating a ResourceStreamRequestTarget
> to a ResourceStreamRequestHandler.
>
> It worked fine in Wicket 1.4.x
>
> I have a button for downloading an installation manual. Which manual should
> be downloaded
> depends on the user's input. In some cases there isn't a manual, and so I
> couldn't use a
> WebRecource, because I wanted to show an infomessage in that case. The
> solution was a Link with
> an onClick. in pseudocode:
>
> Link<String> downloadInstallationmanualButton = new
> Link<String>("downloadinstallationmanual", new Model<String>()) {
>
> @Override
> public void onClick() {
> if (user didn't supply any data) {
> info("Please supply this and that");
> return;
> }
> //create an implementation of IResourcestream called
> InstallationManualResourceStream
> IResourcestream theInstallationManualResourceStream = new
> InstallationManualResourceStream();
> if (theInstallationManualResourceStream.manualNotfound) {
> info("No manual found for your input");
> return;
> }
> ResourceStreamRequestTarget resourceStreamRequestTarget = new
> ResourceStreamRequestTarget(
> theInstallationManualResourceStream,
> theFileName);
> RequestCycle.get().setRequestTarget(resourceStreamRequestTarget);
> }
>
> As I mentioned, this worked perfect.
> As part of the migration to Wicket 1.5.(2), I replaced the last two
> statements by:
>
> ResourceStreamRequestHandler resourceStreamRequestHandler = new
> ResourceStreamRequestHandler(
> theInstallationManualResourceStream,
> theFileName);
> RequestCycle.get().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler);
I don't remember whether ResourceStreamRequestTarget disables the
caching automatically but you can add:
((WebResponse) getResponse()).disableCaching();
somewhere in #onClick()'s body and it should help.
>
> When I click on the button after a server restart and opening of a fresh
> browser, the onClick isn't
> executed. Instead, the browser's (FireFox) save or open popup occurs, with
> download-data of the
> Session before the server restart, a sort of browser caching?
> Only when I have pressed the browser's refresh (F5) twice, the onclick is
> executed.
> After that, it never executes again, and so the IResource isn't updated.
> Shouldn't the onClick always be executed?
>
> What am I doing wrong?
>
> Thanks in advance, Hans Friederichs
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Migrating-a-ResourceStreamRequestTarget-to-a-ResourceStreamRequestHandler-tp3998969p3998969.html
> Sent from the Users forum 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
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org