On Mon, 18 Feb 2013 19:03:41 +0100
Martin Dietze <[email protected]> wrote:

> On Mon, February 18, 2013, Carl-Eric Menzel wrote:
> 
> > Is there a particular reason you're using a page?
> 
> One - unfortunately - big reason: it's legacy code (most of
> which I did not even write myself). The Wicket upgrade is badly
> needed for browser compatibiy, however I don't want to change
> code if it's not absolutely necessary. 

For generating binaries, I would *really* recommend doing this change.
Pages simply are not a good fit for that. Also, it shouldn't be that
big of a change, since you're writing to the Response anyway. Within
AbstractResource's WriteCallback you're going to use the same Response
object, so you can simply copy most of your code over without much
change.

(pseudocode from memory, but close enough)

MyResource extends AbstractResource {
 @Override newResourceResponse(Attributes att) {
  att.setFilename("foo.pdf");
  att.disableCaching();
  att.setContentType("text/pdf");
  att.setWriteCallback(new WriteCallback() {
    @Override writeData(Attributes att) {
      Response r = att.getResponse();
      // write to the response here like you did before
    }
  });
 }
}

Except in this case you won't have to mangle the Response object like
you have to do with the page.

Carl-Eric


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

Reply via email to