Wicket 1.5: How to stop execution after AbstractResource.respond() ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Wicket 1.5: How to stop execution after AbstractResource.respond() ?

Matthias Keller
We have a dynamically generated PDF we send to the user.
I figured out a way to do it, but while it works, it produces lots of
stacktraces in wicket:

I created a PdfResource as subclass of ByteArrayResource.
When the user clicks the button, in the onClick() method we do:

PdfResource pdfResource = new PdfResource(data);
Attributes attrs = new Attributes(requestCycle.getRequest(),
requestCycle.getResponse());
pdfResource.respond(attrs);

This works so far, except that wicket doesn't know the response has
already been sent and tries to display the same page again - I somehow
have to stop processing the response, but how do I do that?
In Wicket 1.4 I could just throw an AbortException() which did just
that. How do I do that in Wicket 1.5 ?

Thanks
Matt


smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: How to stop execution after AbstractResource.respond() ?

Martin Grigorov-4
see how org.apache.wicket.markup.html.link.DownloadLink.onClick() does it

On Thu, May 26, 2011 at 2:52 PM, Matthias Keller
<[hidden email]> wrote:

> We have a dynamically generated PDF we send to the user.
> I figured out a way to do it, but while it works, it produces lots of
> stacktraces in wicket:
>
> I created a PdfResource as subclass of ByteArrayResource.
> When the user clicks the button, in the onClick() method we do:
>
> PdfResource pdfResource = new PdfResource(data);
> Attributes attrs = new Attributes(requestCycle.getRequest(),
> requestCycle.getResponse());
> pdfResource.respond(attrs);
>
> This works so far, except that wicket doesn't know the response has already
> been sent and tries to display the same page again - I somehow have to stop
> processing the response, but how do I do that?
> In Wicket 1.4 I could just throw an AbortException() which did just that.
> How do I do that in Wicket 1.5 ?
>
> Thanks
> Matt
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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

Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: How to stop execution after AbstractResource.respond() ?

Matthias Keller
Thanks Martin

Was looking for such an example but couldn't find one right away. Works
like a charm even though I don't really understand what's going on - is
there some reading about request handler internals in wicket 1.5 somewhere?
The wiki pages do not seem to reflect any 1.5 behaviour yet...

Thanks
Matt

On 2011-05-26 13:55, Martin Grigorov wrote:

> see how org.apache.wicket.markup.html.link.DownloadLink.onClick() does it
>
> On Thu, May 26, 2011 at 2:52 PM, Matthias Keller
> <[hidden email]>  wrote:
>> We have a dynamically generated PDF we send to the user.
>> I figured out a way to do it, but while it works, it produces lots of
>> stacktraces in wicket:
>>
>> I created a PdfResource as subclass of ByteArrayResource.
>> When the user clicks the button, in the onClick() method we do:
>>
>> PdfResource pdfResource = new PdfResource(data);
>> Attributes attrs = new Attributes(requestCycle.getRequest(),
>> requestCycle.getResponse());
>> pdfResource.respond(attrs);
>>
>> This works so far, except that wicket doesn't know the response has already
>> been sent and tries to display the same page again - I somehow have to stop
>> processing the response, but how do I do that?
>> In Wicket 1.4 I could just throw an AbortException() which did just that.
>> How do I do that in Wicket 1.5 ?
>>
>> Thanks
>> Matt
>>


smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Wicket 1.5: How to stop execution after AbstractResource.respond() ?

Martin Grigorov-4
There is a label in CWIKI named "wicket15". All new information about
1.5 uses it. The migration page is also labeled with this label. It is
at the bottom, just click it and you'll see a list of pages for 1.5
that we have currently.

IRequestHandler (IRH) is the improved IRequestTarget from 1.4. Read
RequestCycle's javadoc for more information about the scheduling of
IRequestHandlers.
Basically the idea is that the request processing starts with a IRH
that is resolved by the request url, then later during processing a
new IRH can be scheduled to be executed after the current one (e.g.
using setResponsePage() will do that). At the end only the last
scheduled IRH actually writes to the http response.

On Thu, May 26, 2011 at 3:29 PM, Matthias Keller
<[hidden email]> wrote:

> Thanks Martin
>
> Was looking for such an example but couldn't find one right away. Works like
> a charm even though I don't really understand what's going on - is there
> some reading about request handler internals in wicket 1.5 somewhere?
> The wiki pages do not seem to reflect any 1.5 behaviour yet...
>
> Thanks
> Matt
>
> On 2011-05-26 13:55, Martin Grigorov wrote:
>>
>> see how org.apache.wicket.markup.html.link.DownloadLink.onClick() does it
>>
>> On Thu, May 26, 2011 at 2:52 PM, Matthias Keller
>> <[hidden email]>  wrote:
>>>
>>> We have a dynamically generated PDF we send to the user.
>>> I figured out a way to do it, but while it works, it produces lots of
>>> stacktraces in wicket:
>>>
>>> I created a PdfResource as subclass of ByteArrayResource.
>>> When the user clicks the button, in the onClick() method we do:
>>>
>>> PdfResource pdfResource = new PdfResource(data);
>>> Attributes attrs = new Attributes(requestCycle.getRequest(),
>>> requestCycle.getResponse());
>>> pdfResource.respond(attrs);
>>>
>>> This works so far, except that wicket doesn't know the response has
>>> already
>>> been sent and tries to display the same page again - I somehow have to
>>> stop
>>> processing the response, but how do I do that?
>>> In Wicket 1.4 I could just throw an AbortException() which did just that.
>>> How do I do that in Wicket 1.5 ?
>>>
>>> Thanks
>>> Matt
>>>
>
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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