Handling errors in dynamic Resource generation

2015-01-12 Thread Nick Pratt
I have an AbstractResource modelled after section 15.9 in the Wicket Guide: http://wicket.apache.org/guide/guide/resources.html What is the correct way to handle errors (such as expected dynamic data not available) during the writeCallback? The specific line in the example is:

Re: Handling errors in dynamic Resource generation

2015-01-12 Thread Martin Grigorov
Hi, Override #flushResponseAfterHeaders() (see https://github.com/apache/wicket/blob/wicket-6.x/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java#L673) so that you are able to reset the response if an error occurs while writing the body. Martin Grigorov Wicket

Re: Handling errors in dynamic Resource generation

2015-01-12 Thread Nick Pratt
Thanks Martin. How would this work though - from the callstack, I see newResourceResponse() invoked, followed by flushResponseAfterHeaders(), and then the writeData() callback invocation. So setting a flag in the writeData callback occurs too late. If I try and load the data outside the

Re: Handling errors in dynamic Resource generation

2015-01-12 Thread Martin Grigorov
I've done something similar before: - pass the page id to the resource - if there is an error then use the page id to lookup the page from the stores - if you send the request to the resource with Ajax -- create a new AjaxRequestHandler and schedule it after the current - if this is normal