Hi, On Mon, Nov 7, 2011 at 5:20 PM, hfriederichs <[email protected]> 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: [email protected] > For additional commands, e-mail: [email protected] > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
