Reputation: 744
I have a custom error and expiration page in my wicket application. But in some cases, I would like to have them behave differently (e.g. in a popup that should NOT redirect us to home page).
What are the options for the solution? I assume I can read the page parameters in my error/expiration page from the request object (e.g. "errorpage=no"). But how can I add this query parameter to specific pages in optimal way..?
I'm quite certain someone has solved this already so this would be a great opportunity to share a nice solution here..
Relatively similar question: How to change Wicket behaviour on Page Expired
Upvotes: 1
Views: 1800
Reputation: 780
You could just register a RequestCycleListener that listens "onException" and handles exceptions differently depending on the RequestCycle and otherwise fallback to the default implementation.
(Code based on Wicket 6.6)
getRequestCycleListeners().add(new AbstractRequestCycleListener() {
@Override
public IRequestHandler onException(RequestCycle cycle, Exception ex) {
if (ex instanceof PageExpiredException) {
//handle your pageExpiredException...
if (something) {
return new RenderPageRequestHandler(new PageProvider(HomePage.class));
}
}
return super.onException(cycle, ex);
}
});
Upvotes: 3